Question: ( JAVA ) (ps: if I can get a quick reply, I will be very happy) There are a number of cities in the country

( JAVA ) (ps: if I can get a quick reply, I will be very happy)

There are a number of cities in the country and each city is neighbor to one or more of the other cities. There is a map which contains the distances between each city. (If two cities are not neighbors, the distance is infinite.) You have a number of trucks to carry a number of cargos. A truck has a weight capacity and a volume capacity. A cargo contains some goods supposed to be taken from one city to another. Each cargo has a certain weight and volume. Assume that your drivers are crazy and moving everyday from one city to one of its neighbor cities randomly. If a truck arrives at a city where there is a cargo to be delivered and the truck has enough empty space (in terms of weight and volume) it takes the cargo. If a truck arrives at a city to where there is a cargo on the truck to be delivered, the truck simply delivers the cargo and collects the cargo charge. If two trucks arrive in the same city on a day, they can exchange their cargos in any way as long as the capacity constraints are not violated. As the owner of the cargo company, you want to simulate the system to collect some statistical information. You want to collect the following data:

?The total number of cargos that has been delivered successfully.

?The average time of service ( time of service = the day the cargo is requested the day it is delivered )

?The average time of delivery(time of delivery = the day the cargo is taken- the day it is delivered)

?Total money spent for fuel.

The money spent for fuel for each truck = LPK * MPL * d where d is the distance taken

MPL is a constant denoting the money per liter of fuel and LPK = LPK0*(1+ W/1000) where W is the weight of the currently loaded cargo and LPK0 is a constant denoting liter per kilometer.

?Total money collected

The money collected from a cargo = C0 + UCCw*W+ UCCv*V

where C0 is constant charge per cargo, UCCw is constant charge per weight, UCCv is constant charge per volume, W is the weight of the cargo and V is the volume of the cargo.

?Total distance taken

?Average money for fuel per kilometer (Total money/Total distance)

?The current city of each truck

?The current cargo load of each truck (# of cargo, Total weight and volume)

?Total distance taken by each truck

?Total money collected by each truck

Model the system described above in an Object-Oriented way. Implement necessary classes. Assume that all of the trucks are identical (The same capacity). Start simulation as each of the trucks are empty and randomly placed at a different city. You should simulate the system day by day. Display all of the information during the simulation day by day. (You are free to display in any format. Try to make it as user-friendly as possible) You can implement any kind of exchange cargo policy (taking place when two trucks arrives in the same city on the same day) . Print out the final data after the simulation to a text file named as cargoOutput.txt.

You are strongly encouraged to use interfaces and other possible techniques to make the system as flexible and easy-to-maintain as possible.

Your simulation method (wherever it is) should take the name of the input file as parameter. Call the simulation method from the main() function of Main class.

The format for the input file (a text file) containing the data necessary for the simulation is as follows :

[The # of cities]

[Name s of the cities]

.

.

[The # of neighborhoods]

[The name of City 1] [The name of City2] [The distance between City 1 and City 2]

.

.

[Number of trucks] [Weight capacity of trucks] [Volume capacity of trucks]

[LPK0] [MPL][C0][UCCw][UCCv]

[The # of days to be simulated]

[The # of cargo requests]

[The time (day) of the cargo request] [From] [To][Weight][Volume]

.

.

See the example input file below:

5

Izmir

Istanbul

Ankara

Trabzon

Adana

7

Izmir Istanbul 600

Istanbul Ankara 400

Ankara Trabzon 600

Ankara Adana 500

Izmir Adana 800

Izmir Ankara 600

Istanbul Trabzon 1000

3 100 300

0.04 4.5 3 1.2 1.3

50

10

6 Istanbul Izmir 50 100

9 Izmir Ankara 30 50

15 Trabzon Adana 20 200

16 Adana Ankara 10 50

17 Ankara Adana 70 100

28 Istanbul Izmir 30 60

30 Ankara Izmir 50 50

35 Ankara Istanbul 40 30

40 Istanbul Trabzon 10 40

42 Adana Trabzon 30 20

( JAVA )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!