0% found this document useful (0 votes)
3 views2 pages

Java Order Management System Code

The document contains Java code that defines a parent class 'Order' and a child class 'OnlineOrder' which extends 'Order'. The 'OnlineOrder' class has an overloaded method for placing orders with a delivery address and overrides the billing method. The main method allows users to input order details and processes the order accordingly based on whether it is online or physical.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Order Management System Code

The document contains Java code that defines a parent class 'Order' and a child class 'OnlineOrder' which extends 'Order'. The 'OnlineOrder' class has an overloaded method for placing orders with a delivery address and overrides the billing method. The main method allows users to input order details and processes the order accordingly based on whether it is online or physical.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

​import [Link].

Scanner;​

/​/ ===== Parent class =====​


​class Order {​
​// General method for placing order​
​void placeOrder(String item) {​
​[Link]("Order placed for: " + item);​
​}​

/​/ To be overridden​
​void showBill(String mode) {​
​[Link]("Bill printed. Payment made via " + mode + ".");​
​}​
​}​

/​/ ===== Child class =====​


​class OnlineOrder extends Order {​
​// Overloaded method for online orders with address​
​void placeOrder(String item, String address) {​
​double deliveryCharge = 40.0;​
​[Link]("Online order placed for: " + item);​
​[Link]("Delivery address: " + address);​
​[Link]("Delivery charge applied: ₹" + deliveryCharge);​
​}​

/​/ Overriding billing for online​


​@Override​
​void showBill(String mode) {​
​[Link]("E-Bill emailed. Payment done via " + mode + ".");​
​}​
​}​

/​/ ===== Main =====​


​public class Main {​
​public static void main(String[] args) {​
​Scanner sc = new Scanner([Link]);​
​OnlineOrder order = new OnlineOrder();​

​ [Link]("Enter item: ");​


S
​String item = [Link]();​

​ [Link]("Order type (online/physical): ");​


S
​String type = [Link]();​
​ [Link]("Payment mode (Cash/UPI/Card): ");​
S
​String mode = [Link]();​

​if ([Link]("online")) {​
​[Link]("Enter delivery address: ");​
​String address = [Link]();​
​[Link](item, address); // Overloaded method​
​} else {​
​[Link](item); // Parent method​
​}​

​ [Link](mode);
o // Overridden method​
​[Link]();​
​}​
​}​

You might also like