Question: Simplified Online Shopping System ( Pls solve in JAVA ) The system contains: Person - Attributes: name , address , email - Methods: getDetails (

Simplified Online Shopping System (Pls solve in JAVA)
The system contains:
Person
- Attributes: name ,address ,email
- Methods: getDetails()
Customer
- Attributes: customerID ,shoppingCart (a list of ItemToPurchase objects)
- Methods: addToCart(ItemToPurchase item),removeFromCart(ItemToPurchase item),viewCart()
Cashier
- Attributes: cashierID
- Methods: processPayment(Customer customer),generateReceipt()
ItemToPurchase
- Attributes: itemName ,quantity ,price
- Methods: getTotalPrice()
ShoppingCart
- Attributes: cartItems (a list of ItemToPurchase objects),totalPrice
- Methods: addItem(ItemToPurchase item),removeItem(ItemToPurchase item),calculateTotalPrice()
OnlineShoppingSystem
- main()
Note: You can add more class members (attributes, methods) if you wish.
How It Works:
- The program (main () method) takes user input for both customer and item details.
- It adds items to the customer's shopping cart and calculates the total price.
- It then displays a summary of the purchase, including the total cost.
- The cashier processes the payment and generates a receipt at the end.
Explanation
Get Customer Details: The program starts by prompting the user to enter the customer's name, address, email, and customer ID. This information is used to create a `Customer` object.
Get Cashier Details: Then, the program prompts the user to enter the cashier's ID. A `Cashier` object is created with this ID.
Item Entry: have two versions -
1. Read from keyboard
The program asks how many items the customer wants to purchase.
For each item, the program prompts the user to enter:
- Item Name
- Item Price
- Item Quantity
2. Read the above data from the input file
Each item is then created as an `ItemToPurchase` object and added to the customer's shopping cart.
Display Results: After collecting all the item information, the program
- Displays the customers name, cashier's ID, and the list of items purchased.
- Calculates the total cost by summing up the total price of each item in the shopping cart.
- Displays the total cost. (Sales tax can be considered, but it's optional)
Payment Processing: Finally, the virtual cashier processes the payment, and a receipt is generated for printing or emailing. (just output a message on the console to simulate this step)
Sample Input
Enter customer name: Larry Doe
Enter customer address: 123 Main St
Enter customer email: larry.doe@example.com
Enter customer ID: C123(can be hard coded)
Enter cashier ID: 001(can be hard coded)
Enter number of items to purchase: 2(all item information can also be read from the input file you created)
Enter details for item 1:
Item name: Laptop
Price: 999.99
Quantity: 1
Enter details for item 2:
Item name: Headphones
Price: 49.99
Quantity: 2
Sample Output
------ Order Summary ------
Customer: Larry Doe
Cashier ID: 001
Items Purchased:
1 x Laptop @ $999.99 each
2 x Headphones @ $49.99 each
Total Cost: $1099.97
Processing payment for Larry Doe
Generating receipt...

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!