Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

Suppose you have persons John, Mary, Peter, Alan, Anna and James who live in the cities London, Paris, Moscow and New York and drive use these modes of transportation Private Car, Train, Bicycle, walking and bus and do the jobs of clerk, dentist, artist, and musician for which they earn various salary scales.

I want to work more on associating/displaying each person based on the information that relate to them. Below are 3 tables I just created to make it easy to view the data applicable to these persons. I also created 3 sample classes below the tables so we can see the data we should display for each person. These I believe give a good idea of how you can pass data into methods of other classes

PERSON
-------------
NAME       Job           CITY          SALARY           PREFERRED TRANSPORTATION
John       Clerk         London        5000              Private Car
Mary       Dentist       Paris         10000             Train
Peter      Artist        Paris         7000              Bicycle
Alan       Clerk         New York      2000              Train
Anna       Musician      Londo         15000             Walking
James      Unemployed    Moscow         0                Bus
Tony       Artist        London        3500              Motor Bike
Julie      Nurse         New York      3000              Bus










CITY   
------------                     
  CITY NAME              TRANSPORTATION AVAILABLE          COST


  London                       Train                       5
  Paris                         Bus                        10
  New York                      Train                       8
  Moscow                         Boat                      2










TRANSPORTATION
--------------------
TRANSPORTATION                      SPEED

Train                               Average                             
Bus                                 Fast 
Boat                                Slow 


I have created 3 classes just to hold the data/methods as below:

Java
class Person{

    string name;
    string City;
    string job;
    double salary;
    string preferredTransport;
    string availableTransport;
    string transportSpeed;
    
}


class Transportation{

    string transportationMode;
    string howSafe;
    

}

class City{

    string cityName;
    string transportationModeAvailable;
    double transportationCost ;
    
}


Kindly evaluate this i need to idea to solve this problem
Posted
Updated 6-Feb-14 4:01am
v3
Comments
KarstenK 6-Feb-14 8:41am    
you need to store the infos in an class to get better access.

so you can

GetCostFromCity( string cityName )
{
//Loop tru array and find
//return the special cost


}
nuke_infer 6-Feb-14 8:53am    
can you please give idea where do i need to start this?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900