Stage 1-A ticket to book In this stage, you will implement a basic online shopping cart. You are required to create one
Posted: Fri May 20, 2022 10:52 am
Stage 2 - A basic shopping cart You must complete Stage 1 before attempting Stage 2. If Stage 1 has not been completed Stage 2 will not be assessed. In this stage, you will create a basic shopping cart. The shopping cart is supposed to (1) store a customer's information; (2) allow a customer to add items; and (3) compute the total cost of the items within the shopping cart. Implement the class Shopping Cart. Specifically, the Shopping Cart class should contain: O Private fields o String customerName o String date o Ticket[] inCart Tickets static final int CAPACITY of value 5 (provided) o int count . No-argument constructor Shopping Cart() o Initialize customerName to String "UNKNOWN" Initialize date to String "1 May 2022" Initialize cartTickets to an empty array of size CAPACITY o Initialize count to O 0 0 Constructor Shopping Cart(String name, String date) Initialize instance variable customerName to name o Initialize instance variable date to date Initialize in CartTickets to an empty array of size CAPACITY Initialize count to O o o . Public accessor getCustomerName() which returns the customer name of the shopping cart Public mutator setCustomerName(String name) which sets the customer name Public accessor getDate() which returns the sign up date of the customer Public mutator setDate(String date) which sets the current date of shopping cart . . Public member method add(Ticket ticket), which adds the ticket parameter to inCart Tickets array. The method determines whether the ticket passed in is not null and is different to any ticket in inCart Tickets. If yes, it adds ticket to the shopping cart and returns true. Otherwise, it prints a message "Ticket invalid or already added." and returns false. Note, all tickets should have different names ignoring cases. "Star wars", "star wars" and "Star Wars" are considered the same. If the shopping cart is full, the ticket then cannot be added. It prints "SHOPPING CART IS FULL" and returns false. Public member method getTotalCount() which returns quantity of all tickets in cart. Note that the quantity of all tickets must be computed as the total quantity of all different tickets in the cart. E.g. if there are 1 sale of 3 tickets and 1 sale of 1 ticket, the method will return 4, not 2. Public member method getCost() which returns the total cost of the tickets in cart. Public member method printTotal() which outputs (1) the customer and the date; (2) number of total sales in the shopping cart; (3) the information of each sale in the shopping cart; and (4) the total cost of the shopping cart. If the cart is empty, outputs (1) the customer and the
date; and (2) the message "SHOPPING CART IS EMPTY.". Please refer to the example outputs when implementing this method. Complete stage2(Shopping Cart cart) method in CartManager. Ask user to enter name and date. Sets the customerName and date of cart passed in. Print the information of the shopping cart created by calling printTotal() (note, it is the first-time calling printTotal()). Prompt the user for two ticket sales, create two objects of the Ticket class, and add these two objects into the shopping cart created. Hint: Before prompting for the second item, you may need to call scanner.nextLine(); to allow the user to input a new string (depends on your program). Print info of the shopping cart by calling print Total() (calling printTotal() for the second time). Example outputs are as follows. Given the same user input, your program is expected to produce the same output. Only minor format differences (e..g., extra line break) are allowed. Example output after printTotal() is called for the first time: ********** Stage 2 ********** Enter the name of the customer: Andrew Smith User Prompt in stage20 Enter the current date: 1 May 2022 Andrew Smith - 1 May 2022 SHOPPING CART IS EMPTY Example output of the first printTotall) call Example outputs after printTotal() is called for the second time: Enter the name of the ticket: The Matrix Reloaded Enter the ticket price: 15 Enter the quantity: 3 Enter the name of the ticket: Top Gun Enter the ticket price: 25 Enter the quantity: 2 Andrew Smith - 1 May 2022 Number of tickets: 5 The Matrix Reloaded 3 x $15 = $45 Top Gun 2 X $25 = $50 Example output of the second printTotall) call Total cost: $95
Stage 3 - Updating the shopping cart You must complete Stage 2 before attempting Stage 3. If Stage 2 has not been completed Stage 3 will not be assessed. In this stage, you will need to allow user to update the items already added to the shopping cart. You need to extend the Shopping Cart class by adding: Public method remove Ticket(String ticketName) It removes a ticket from the shopping cart if its name matches with the parameter ticketName. After removing, output this message "Ticket ticketName removed from the cart". It returns true in this case. If no item in the cart matches with ticketName, print this message "Ticket not found. Cart remains unchanged.” It returns false in this case. Public method update Ticket(String ticketName) Modifies a ticket's quantity and returns true if successful. If an item with a matched name of the parameter ticketName can be found in cart, prompt the user to enter the new quantity with the message "Please enter the new quantity:". Update the ticket quantity according to the user input. If the ticket cannot be found (by ticketName), print the message: "Ticket not found. Cart remains unchanged." and return false. . Public method checkout() Generate a summary of the shopping cart by calling printTotal(). Allow customer to check-out. Removes all items from the shopping cart and returns true. If the shopping cart is empty, do not generate a summary. Instead, output the message "SHOPPING CART IS EMPTY." and returns false. 0 Implement stage3() method in CartManager. Note that in main(), stage3() will work on the cart object that has been updated by Stage 2. Ask user for the ticket to be removed. Perform the removal by calling remove Ticket(String ticketName), and print the summary of the cart by calling the printTotal(). Next, ask for the ticket name to be modified, then call update Ticket(String ticketName). Print the information of the shopping cart by calling the printTotal() method. Finally, prompt the user to check- out and call the checkout() method. Example outputs are as follows. Given the same user input, your program is expected to produce the same output as follows. Only minor format differences (e..g., extra line break) are allowed. ********** Stage 3 ********** Do you want to remove a ticket from the cart? Y/N Y Enter the name of the ticket: Case insensitive top gun Top Gun removed from the shopping cart. Andrew Smith - 1 May 2022 Number of tickets: 3 The Matrix Reloaded 3 x $15 = $45 Total cost: $45
Stage 4 – VIP Shopping Cart You must complete Stage 3 before attempting Stage 4. If Stage 3 has not been completed Stage 4 will not be assessed. In this stage, you will extend the program to create a shopping cart for VIP customer. VIP customers have a few privileges: (1) If the total price of purchased ticket is greater or equal to $100, then the last ticket is free for one. Using the last example from Stage 3, Andrew Smith ordered 4 tickets for Top Gun but only needs to pay for 3, e.g. $75. (2) Collect points after check-out. The number of points collected is equal to the cost that a customer actually pays at check-out. If a VIP pays $75 at check-out, then 75 points will be rewarded. (3) A VIP customer can use the points to pay at check-out. Specifically, every 20 points can be used equivalently as $1. When a VIP proceeds to check-out, your program should prompt the user for number of points he/she wishes to use. When using points to pay, a customer can only use multiples of 20 points, e.g., 20, 40, 100 points etc. If the customer enters a number that is not multiples of 20, the nearest lower multiple of 20 will be used, e.g. 80 for 95, 40 for 49. If the customer enters a number greater than the total points available, print the message: "Not enough points. Please re-enter or enter -1 to quit point redeeming.". If a valid number is entered, deduct the points from balance and continue the checkout. If -1 is entered, the program will proceed with the normal checkout. To achieve the above requirements, you will need to implement a new class VIP Cart that is a subclass of the Shopping Cart class. Additional private fields, new methods or overridden methods may be added. You then need to implement stage4() method. In this method, prompt the user to create a VIP shopping cart. Add one item to the shopping cart, and then call checkout(). Example outputs are as follows. Given the same user input, your program is expected to produce the same output as follows. Only minor format differences (e..g., an extra line break) are allowed. Example, a VIP ordered 3 tickets of "The Matrix Reloaded" and redeemed 100 points at checkout. ********** Stage 4 ********** Enter the name of the VIP customer: Andrew is a VIP! Andrew Smith Enter the current date: 1 May 2022 Enter the VIP points available: 350 Enter the name of the ticket: The Matrix Reloaded Enter the ticket price: 15 Enter the quantity: 3
Andrew Smith 1 May 2022 Number of tickets: 3 The Matrix Reloaded 3 x $15 = $45 Total cost: $45 Do you want to checkout? Y/N Y How many points to redeem? Enter -1 to checkout without using points. 118 100 points redeemed, not 118 points! Redeemed 100 points for $5 Total price paid: $40 40 VIP points added. Available 290 points. Thank you for shopping