Step 1: Extend the ItemToPurchase class per the following specifications:
- Private fields
- string itemDescription - Initialized in default constructor to "none"
- Parameterized constructor to assign item name, item description, item price, and item quantity.
- Public member methods
- setDescription() mutator & getDescription() accessor
- printItemCost() - Outputs the item name followed by the quantity, price, and subtotal
- printItemDescription() - Outputs the item name and description
Ex. of PrintItemCost() output:
Bottled Water 10 @ $1 = $10
Ex. of PrintItemDescription() output:
Bottled Water: Deer Park, 12 oz.
- ShoppingCart.java - Class definition
- ShoppingCartManager.java - Contains main() method
Build the ShoppingCart class with the following specifications.
- Private fields
- String customerName - Initialized in default constructor to "none"
- String currentDate - Initialized in default constructor to "January 1, 2016"
- ArrayList cartItems
- Default constructor
- Parameterized constructor which takes the customer name and date as parameters
- Public member methods
- getCustomerName() accessor
- getDate() accessor
- addItem()
- Adds an item to cartItems array. Has a parameter of type ItemToPurchase. Does not return anything.
- removeItem()
- Removes item from cartItems array. Has a string (an item's name) parameter. Does not return anything.
- If item name cannot be found, output a message: Item not found in cart. Nothing removed.
- modifyItem()
- Modifies an item's description, price, and/or quantity. Has a parameter of type ItemToPurchase. Does not return anything.
- If item can be found (by name) in cart, check if parameter has default values for description, price, and quantity. If not, modify item in cart.
- If item cannot be found (by name) in cart, output a message: Item not found in cart. Nothing modified.
- getNumItemsInCart()
- Returns quantity of all items in cart. Has no parameters.
- getCostOfCart()
- Determines and returns the total cost of items in cart. Has no parameters.
- printTotal()
- Outputs total of objects in cart.
- If cart is empty, output a message: SHOPPING CART IS EMPTY
- printDescriptions()
- Outputs each item's description.
- If cart is empty, output a message: SHOPPING CART IS EMPTY
Step 3: In main(), prompt the user for a customer's name and today's date. Output the name and date. Create an object of type ShoppingCart.
Step 4: Implement the following menu functions in the ShoppingCartManager class
- printMenu()
- Prints the following menu of options to manipulate the shopping cart.
- executeMenu()
- Takes 3 parameters: a character representing the user's choice, a shopping cart, and a Scanner object. Performs the menu options described below in step 5, according to the user's choice.
Step 5: Implement the menu options
Step 5a: In main(), call printMenu() and prompt for the user's choice of menu options. Each option is represented by a single character.
If an invalid character is entered, continue to prompt for a valid choice. When a valid option is entered, execute the option by calling executeMenu(). Then, print the menu and prompt for a new option. Continue until the user enters 'q'.
Hint: Implement Quit before implementing other options.
Step 5b: Implement "Output shopping cart" menu option in executeMenu().
Step 5c: Implement "Output items' descriptions" menu option in executeMenu().
Step 5d: Implement "Add item to cart" menu option in executeMenu().
Ex:
ADD ITEM TO CART Enter the item name: Nike Romaleos Enter the item description: Volt color, Weightlifting shoes Enter the item price: 189 Enter the item quantity: 2Step 5e: Implement "Remove item from cart" menu option in executeMenu().
Ex:
REMOVE ITEM FROM CART Enter name of item to remove: Chocolate ChipsStep 5f: Implement "Change item quantity" menu option in executeMenu().
Hint: Make new ItemToPurchase object and use ItemToPurchase modifiers before using modifyItem() method.
- printMenu()
Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 5 images
- Object-oriented programmingcreate a program that manages the production of a company. The production of each of the months of the year 2021 is saved, the average production of the year is also stored.Include a method to display all company information.Include at least three public or private type attributes. If they are private don't forget to include the getter and setter methods ONLY for private attributes.Include both default and parameterized constructors.Your program must allowShow all company dataRequest company dataShow the name of the month that had the highest production.Show the name of all the months with production less than the annual average.Identify the methods that are of the class and those that are of the main program.DO NOT forget that attributes, methods, classes, objects and messages are written in English.The MIN and MAX methods must be part of the main program. NOT of the classarrow_forwardComputer programmingarrow_forwardObject-oriented programmingProgram the employee class as indicated in the diagramTo calculate the salary, just multiply the number of hours by the payment per hour.The capture method asks the user for the data for the three attributes, asks for the hours worked and the payment per hour and with these data calculates the salary.The show method displays all of the employee's data.Do not forget the getter and setter methods only for attributes of type privateYour company has 7 employees and you would like1. Capture the data of each employee2. Show the data of each employee3. Show the data of a particular employee4. Calculate and display the average salary5. Calculate and display the name of the employee with the highest salary6. Calculate and display the name of the employee with the lowest salary7. Calculate and show the total payment you will make for all your employeesarrow_forward
- Create a Class called Transaction with: instance variables: stock - your stock class type - char -> b or s (buy/sell) quantity - can be fractional price - buy/sell price when - LocalDate constructors: constructor with parameters for stock, type and quantity. - sets the price from the stock price instance variable - sets when from LocalDate getters and setters for each instance variablearrow_forwardDesign a Ship class that has the following members:• A field for the name of the ship (a string).• A field for the year that the ship was built (a string).• A constructor and appropriate accessors and mutators.• A toString method that displays the ship's name and the year it was built.Disign a CruiseShip class that extends the Ship class. The CruiseShip class should have thefollowing members:• A field for the maximum number of passengers (an int).• A constructor and appropriate accessors and mutators.• A toString method that overrides the toString method in the base class. The CruiseShipclass's toString method should display only the ship's name and the maximum number ofpassengers.Design a CargoShip class that extends the Ship class. The CargoShip class should have thefollowing members:• A field for the cargo capacity in tonnage (an int).• A constructor and appropriate accessors and mutators.• A toString method that overrides the toString method in the base class. The CargoShipclass's…arrow_forwardCode the StudentAccount class according to the class diagramMethods explanation:pay(double): doubleThis method is called when a student pays an amount towards outstanding fees. The balance isreduced by the amount received. The updated balance is returned by the method.addFees(double): doubleThis method is called to increase the balance by the amount received as a parameter. The updatedbalance is returned by the method.refund(): voidThis method is called when any monies owned to the student is paid out. This method can onlyrefund a student if the balance is negative. It displays the amount to be refunded and set thebalance to zero. (Use Math.abs(double) in your output message). If there is no refund, display anappropriate message.Test your StudentAccount class by creating objects and calling the methods addFees(), pay() andrefund(). Use toString() to display the object’s data after each method calledarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education