Answered step by step
Verified Expert Solution
Question
1 Approved Answer
package week_10; import java.io.Console; import java.sql.SQLException; import static input.InputUtils. positiveIntInput ; import static input.InputUtils. stringInput ; class ProductManager { ProductDB database; private String menu =
package week_10; import java.io.Console; import java.sql.SQLException; import static input.InputUtils.positiveIntInput; import static input.InputUtils.stringInput; class ProductManager { ProductDB database; private String menu = "" + "1. Show all products " + "2. Add a product " + "3. Edit a product's quantity " + "4. Delete a product " + "9. Quit"; public static void main(String[] args) throws SQLException { ProductManager productMananger = new ProductManager(); productMananger.start(); } public void start() throws SQLException { database = new ProductDB(); showMenuDoAction(); } private void showMenuDoAction() { int choice; do { System.out.println(menu); choice = positiveIntInput("Enter choice"); switch (choice) { case 1: showAll(); break; case 2: addProduct(); break; case 3: editProductQuantity(); break; case 4: deleteProduct(); break; case 9: break; default: System.out.println("Invalid choice, please try again"); } } while (choice != 9); } protected void addProduct() { } protected void showAll() { String allData = get // TODO write and call method in ProductDB to fetch all products, sorted by product name. // TODO display all products } // TODO ask user for product name and quantity // TODO write and call method in ProductDB to add this product // TODO Deal with product alread existing in DB. Do not add another product with the same name. protected void editProductQuantity() { // TODO ask user which product to edit // TODO write and call method in ProductDB to edit this product's quantity. Display confirmation message if product found and quantity edited. // TODO Deal with product not existing in DB - do not make any edits, display helpful message to user } protected void deleteProduct() { String name = stringInput("Enter name of product to delete "); // TODO ask user for the name of a product to delete // TODO write and call method in ProductDB to delete this product's record from the database. Display confirmation message. // TODO Deal with product not existing in DB - do not make any edits, display helpful message to user } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started