CJCoding With Joseph
15free / daySign inCreate account

Order is an abstract class with a protected subtotal and an abstract method total(). Write one concrete subclass, and a method that adds up orders through the abstract type.

Requirements: 1. DeliveryOrder extends Order. Its public constructor DeliveryOrder(double subtotal) passes the subtotal to the Order constructor. 2. total() in DeliveryOrder returns the subtotal plus a delivery fee of 4.99. 3. Till has a method public static double sum(Order[] orders) that returns the sum of total() over every order in the array, and 0.0 for an empty array. 4. sum must call total() on each element. The tests add their own subclass, PickupOrder, whose total() is just the subtotal, so do not test for DeliveryOrder inside the loop. 5. Till is the public class. Keep DeliveryOrder without the word public.

Do not change the Order class.

Do NOT write a main method.

Expected output

24.99
47.48

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
Abstract ClassesClasses
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.