Question: Write a class encapsulating the concept of an address, called Address, having a streetAddress, city, state, and zipCode as instance variables. The Address class contains

Write a class encapsulating the concept of an address, called Address, having a streetAddress, city, state, and zipCode as instance variables. The Address class contains a toString() method for returning a string of an address.

(b) Write a class encapsulating the concept of a package, called Package, which contains instance variables for TrackingID, Weight (in ounces), Cost, shipMethod, and Destination. shipMethod is a variable of an enumerated type called Shipping, which defines the following constants for a shipping method {Air, Ground, Sea}. Destination is a reference to an object of the Address class. The Package class includes the following: ? A constructor that accepts arguments for the weight, and shipping method. The constructor calls a method called calculateCost() to determine the shipping cost. ? The calculateCost() method computes the cost of a package delivery based on the method of shipping. The shipping cost is determined based on the following table: ? Accessesor, mutator methods for the Weight, shipMethod, and Destination instance variables. The mutator methods for the Weight and shipMethod should call the calculateCost() method in order to recalculate the package cost. ? A method, called GenerateID, that accepts a Random class object which is used to generate and set the TrackingID by a random number of 6 digits, then returns its value. ? toString() method that returns a nicely formatted string of the package information.

weight air ground sea

1-8 4.00 1.80 0.55

9-16 6.00 2.80 1.50

17+ 9.00 4.00 2.00

(c) Write a client class, called PackageDelivery, that allows the user to create any number of packages and stores all the user entries in a packageList as an ArralyList object of Package objects. The client prompts the user for the required fields for the package weight, shipping method, and destination. The client uses the method, GenerateID, of the package class to generate a tracking ID of 6 digits. The client should display the contents of the packageList object on the screen. Implement a scenario for removing and adding some packages from the packageList then display it again. (Note: Implement the classes in separate files.)

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!