Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DresserFrontEnd {
- public static Dresser clothes;
- public static Scanner keyboard;
- public static void main(String[] args) {
- greeting();
- printOptions();
- printClothing(clothes);
- //null point error #1 here ^
- //creating UI
- boolean exit = false;
- while (!exit)
- {
- int choice = keyboard.nextInt();
- switch (choice)
- {
- case 1: //adding clothes
- clothes.addClothing(clothingDialogue());
- break;
- case 2: //removing clothes
- clothes.removeClothing(clothingDialogue());
- break;
- case 7: //printing the drawers contents
- printClothing(clothes);
- break;
- case 9: // to exit
- exit = true;
- System.exit(0);
- break;
- default:
- System.out.println("Cannot use that input");
- }
- System.out.println("!");
- }
- }
- public static void greeting()
- {
- System.out.println("Welcome to the Dresser!");
- }
- public static void printClothing(Dresser clothes)
- {
- clothes.printDresser();
- //null point exception 2 on this line ^
- }
- //showing user possible options
- public static void printOptions()
- {
- System.out.println("Enter 1: to add an item.Enter 2: to remove an item. Enter 7: to print out the dresser content.Enter 9: to quit");
- }
- //sorting
- public static Dresser clothingDialogue()
- {
- Dresser clothes = new Dresser();
- int choice = 0;
- System.out.println("Enter the type \nEnter 2: if it's a color");
- choice = keyboard.nextInt();
- while (choice != 1 && choice != 2)
- {
- System.out.println("Invalid. Try again.");
- choice = keyboard.nextInt();
- keyboard.nextLine();
- }
- switch (choice)
- {
- case 1: //creating type
- System.out.println("Enter the type of garment. It may be undergarment, socks, stockings, top, bottom, or cape");
- String type = keyboard.nextLine();
- keyboard.nextLine();
- break;
- case 2: //creating color
- System.out.println("It may be brown, pink, orange, green, blue, purple, or red.");
- String color = keyboard.nextLine();
- break;
- default:
- clothes = new Dresser ();
- }
- clothes.addClothing(new Dresser());
- clothes.removeClothing(new Dresser());
- return clothes;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement