Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

Students also viewed these Databases questions