Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write the Java classes shown in tha fall... To be answered in (45) Minutes / to Marks A: - Create an interface called Deliverable that
Write the Java classes shown in tha fall... To be answered in (45) Minutes / to Marks A: - Create an interface called Deliverable that contains two methods: - shippingcost: takes no argument and return double. - getReceiver: takes no argument and return String - Create an abstract class Shipment that implements Deliverable and has Receiver( String), weight (double), and number ( generic type T could be integer or double or String). Define the following methods: Constructor that initializes instant variables. getReceiver: tasks no argument and return the receiver. - Override the tostring () to returns a String composed of a shipment information. - Create a class Envelope that extends the Shipment class and has type (String). Define the following methods: - Constructor that initializes instant variables. - Override the shippingcost() method to returns the cost of shipping an envelope as a double value (pileorof stamp 2 SAR + weight * 2 SAR ) - Override the tostring () to returns a String composed of an envelope information. (see the running example) D: 1.5 Marks - Create a class Parcel that extends the Shipment class and has height(double), width (double) and length (double) Define the following methods: - Constructor that initializes instant variables. Override the shippingcost () method to return a double value of the shipping cost for a parcel is calculated as fellows: Cost = (height * width * length ) * 2 + weight SAR - Override the tostring() to returns a String composed of a parcel information.(see the running example) Part 2: To be answered in (15) Minutes / 4 Marks Create the driver class Tester that contains a main method that does the following (in the specified order): 1. Instantiate an array of size 2 of Deliverable interface. 2. Create one object from each Envelope and Parcel class. 3. Insert the created objects into the array. 4. Loop over the created array and do the following: - Display the shipping information - Show the shipping cost. Running example: Envelope: Shipment receiver: Ahmed, weight: 12.00, number: 1244-23, type: A4, Shipping cost: 26.0 SAR Parcel: Shipment receiver: Norah, weight: 500.00, number: 12345 , width: 10.00, length: 3.00, height: 5.00, Shipping cost: 800.0 SAR
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started