Question: can you make an algorithim for this Virtuous Crisis Undertakings ( VCU ) is a disaster relief organization. They distribute relief supplies to various areas
can you make an algorithim for this Virtuous Crisis Undertakings VCU is a disaster relief organization. They distribute relief supplies to various areas that include different levels of infrastructure and danger. You will design a data type using abstraction that models a shipment and another one that models a cargo flight for these supplies to help VCU match shipments to appropriate cargo flights.
The name of the shipment Java class is Shipment.java. The characteristics that define a Shipment are the following:
destination: String
shipmentID: int
weight: double
roads: none, DIRT, PAVED
runways: none, NEARBY, FAR
danger: none, MODERATE, CONSIDERABLE, HIGH
The fields above in the righthand column will be expressed as Java Enumeration Types to restrict the values that can be assigned to these instance variables. These types will be located in their own classes with their own separate files and the name of these classes must match the names provided by the UML diagrams below
The parameterized constructor should have the following definition:
public ShipmentString aDestination, int aShipmentID, double aWeight, Roads aRoads, Runways aRunways, Danger aDanger
The constructor will pass in the destination, the shipment id the weight, the roads, the runways, and the danger of the shipment.
The default constructor will assign the default values to the instance variables of the shipment. The default values will be as follows: an empty string for the destination, for the shipment id for the weight, and the first value in each enumerated list.
The Shipment class will have getters and setters for each instance variable as well as a toString method that prints each instance variable of the Shipment object indented by a tab on its own line. You will start the printing with a new line and then a tab. All floating point variables should be formatted to two decimal points with String formatting.
The other object that needs to be defined represents the cargo flight for the shipments. The name of the Java class is CargoFlight.java. The instance variables of a cargo flight are the following:
flightNumber: String
weightCapacity: double
volumeCapacity: double
danger: String
shipments: ArrayList
The parameterized constructor should have the following definition:
public CargoFlightString aFlightNumber, double aWeightCapacity, double aVolumeCapacity, String aDanger
This constructor will initialize all properties making sure to initialize the values passed in for the first four properties. It will also create an empty array list in the shipments property.
The default constructor will place an empty String into each of the String property fields, into each of the double fields, and will also create an empty array list in the shipments property.
You will have a getter and setter for the flightNumber, weightCapacity, volumeCapacity, and danger attributes. You will have an addShipment method that will take in a Shipment object and add it to the CargoFlight objects ArrayList called shipments. You will have a getNumShipments that will let you know how many Shipment objects are associated with a CargoFlight object or are in the ArrayList for that cargo flight. You will have a getShipments method that will return the ArrayList of Shipment objects associated with the CargoFlight object. The CargoFlight class will also have a toString method to output the CargoFlight information, separated by newlines, along with the shipments associated with it
Here are two examples of what a typical output would be from calling the toString method for a cargo flight who has two Shipments and for a cargo flight who has one Shipment. Note that the CargoFlights toString method must also call the toString method on each individual Shipment object the CargoFlight has after it prints the String, Shipments:
HIGH
Shipments:
NYC
DIRT
FAR
CONSIDERABLE
SF
PAVED
NEARBY
MODERATE
HIGH
Shipments:
Boston
PAVED
NEARBY
none
Make sure that you use the UML Class Diagrams below to build your classes. You will test your classes using the JUnit tests provided. You can also test your code by building a CargoFlightShipmentTest.java file, which will have a main method. This file is where you will build CargoFlight and Shipment objects and perform the methods from the classes on them.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
