Question: Use Java to add FileWriter.write into the following code to allow user input to be added into clothes.txt and shoes.txt respectively: When the user enters
Use Java to add FileWriter.write into the following code to allow user input to be added into "clothes.txt" and "shoes.txt" respectively: When the user enters "+" then "C", allow the user to input a new item (String item, String color, String size, int amount) and store it into "clothes.txt". When the user enters "+" then "S", allow the user to input a new item (String item, String color, int size, int amount) and store it into "shoes.txt". Part of current Tester Class is here:
System.out.println("Press \"1\" to start and press \"0\" to end this system."); boolean start = false; while (!start) { int value = sc.nextInt(); if (value == 0) { start = true; System.out.println("System close! Winter vacation is coming!"); } else if (value == 1) { System.out.print("Please enter \"i\" to get info, \"+\" for adding items, and \"-\" for selling items: "); String check = sc.next(); if (check.equals("i")) { Manage.getInfo(sc, clothes, shoes); } else if (check.equals("+") || check.equals("-")) { Manage.action(check, sc, clothes, shoes); } System.out.println(" Press \"1\" to start and press \"0\" to end this system."); } }
}
current Manage Class is here:
public static void action(String check, Scanner sc, ClothesList clothes, ShoesList shoes) { if (check.equals("-")) { System.out.print("Which category do you want to remove? (clothes for 1 and shoes for 2 ) "); int category = sc.nextInt(); if (category == 1) { System.out.println("Please enter the item, color, size, and amount you'd like to remove: "); clothes.saleClothes(sc.next(), sc.next(), sc.next(), sc.nextInt()); } else if (category == 2) { System.out.println("Please enter the item, color, size, and amount you'd like to remove: "); shoes.saleShoes(sc.next(), sc.next(), sc.nextInt(), sc.nextInt()); } } else if (check.equals("+")) { System.out.print("Which category do you want to add? (clothes for 1 and shoes for 2) "); int category = sc.nextInt(); if (category == 1) { System.out.println("Please enter the item, color, size, and amount you'd like to add: "); clothes.sellerPurchaseClothes(sc.next(), sc.next(), sc.next(), sc.nextInt()); } else if (category == 2) { System.out.println("Please enter the item, color, size, and amount you'd like to add: "); shoes.sellerPurchaseShoes(sc.next(), sc.next(), sc.nextInt(), sc.nextInt()); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
