Advertisement
scaawt

Homework06(Front End)

Dec 4th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DresserFrontEnd {
  4.  
  5.   public static Dresser clothes;
  6.   public static Scanner keyboard;
  7.  
  8.   public static void main(String[] args) {
  9.     greeting();
  10.     printOptions();
  11.    printClothing(clothes);
  12.     //null point error #1 here ^
  13.    
  14.     //creating UI
  15.     boolean exit = false;
  16.     while (!exit)
  17.     {
  18.       int choice = keyboard.nextInt();
  19.       switch (choice)
  20.       {
  21.         case 1: //adding clothes
  22.           clothes.addClothing(clothingDialogue());
  23.           break;
  24.         case 2: //removing clothes
  25.         clothes.removeClothing(clothingDialogue());
  26.         break;
  27.         case 7: //printing the drawers contents
  28.           printClothing(clothes);
  29.           break;
  30.         case 9: // to exit
  31.           exit = true;
  32.           System.exit(0);
  33.         break;
  34.         default:
  35.           System.out.println("Cannot use that input");
  36.       }
  37.       System.out.println("!");
  38.     }
  39.   }
  40.  
  41.  
  42.   public static void greeting()
  43.   {
  44.     System.out.println("Welcome to the Dresser!");
  45.   }
  46.   public static void printClothing(Dresser clothes)
  47.   {
  48.     clothes.printDresser();
  49.     //null point exception 2 on this line ^
  50.   }
  51.        //showing user possible options
  52.   public static void printOptions()
  53.   {
  54.     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");
  55.   }
  56.  
  57.  
  58.   //sorting
  59.   public static Dresser clothingDialogue()
  60.   {
  61.    Dresser clothes = new Dresser();
  62.     int choice = 0;
  63.     System.out.println("Enter the type \nEnter 2: if it's a color");
  64.     choice = keyboard.nextInt();
  65.     while (choice != 1 && choice != 2)
  66.     {
  67.       System.out.println("Invalid. Try again.");
  68.       choice = keyboard.nextInt();
  69.       keyboard.nextLine();
  70.     }
  71.     switch (choice)
  72.     {
  73.       case 1: //creating type
  74.         System.out.println("Enter the type of garment. It may be undergarment, socks, stockings, top, bottom, or cape");
  75.         String type = keyboard.nextLine();
  76.         keyboard.nextLine();
  77.       break;
  78.      
  79.       case 2: //creating color
  80.         System.out.println("It may be brown, pink, orange, green, blue, purple, or red.");
  81.         String color = keyboard.nextLine();
  82.         break;
  83.        
  84.       default:
  85.         clothes = new Dresser ();
  86.     }
  87.    
  88.     clothes.addClothing(new Dresser());
  89.     clothes.removeClothing(new Dresser());
  90.     return clothes;
  91.   }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement