Loading...
Loading...
Loading...
A canteen order is made of lines such as "2 x Samosa". A line makes no sense outside its order, so the order creates its lines itself.
Write OrderLine (item, price, quantity, amount()) and Order with addLine(String item, int price, int qty), which creates the line inside, and printBill().
QTY x ITEM = Rs. AMOUNT, then Total: Rs. T.Example
Input
3 Samosa 15 4 Tea 10 2 Vada_Pav 20 1
Output
4 x Samosa = Rs. 60 2 x Tea = Rs. 20 1 x Vada_Pav = Rs. 20 Total: Rs. 100
The order owns its three lines; the total is 60 + 20 + 20.
Try the problem first. Open one hint at a time.
main passes only data; addLine calls new OrderLine(...).
Each line works out its own amount(); the order only adds them up.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor