package class9_1_ClothesChooser; // MSOE. Dr. Yoder. 01 November 2015. import java.util.Random; import java.util.Scanner; public class ClothesChooser { private ClothingList shirts; private ClothingList pants; private Clothing currentShirt; private Clothing currentPants; private Scanner in; private Random generator; public static void main(String[] args) { ClothesChooser chooser = new ClothesChooser(); chooser.run(); } public void run() { createWardrobe(); in = new Scanner(System.in); generator = new Random(); int choice = 1; System.out.println("Welcomd to the clothing chooser!"); while(choice != 0) { System.out.println(); System.out.println("Options:"); System.out.println("1: Pick a random Selection"); System.out.println("2: Enter a selection manually"); System.out.println("3: Check if current selection matches"); System.out.println("0: Exit"); System.out.println("(There are "+ Clothing.getNumArticles()+" total articles of clothing)"); System.out.println(); System.out.print("Please enter an option: "); choice = in.nextInt(); if(choice == 1) { pickRandomSelection(); } else if(choice ==2) { enterASelectionManually(); } else if(choice == 3) { checkCurrentSelection(); } else if (choice == 0) { /* will exit. Do nothing */ } else { System.out.println("Warning: Unexpected option: "+choice); } } } private void checkCurrentSelection() { if(currentShirt.isMatchTo(currentPants)) { System.out.println("The current selection matches."); } else { System.out.println("The current selection doesn't match"); } } private void createWardrobe() { pants = new ClothingList("pant", new Clothing("pant", new Color(), Style.PLAIN), new Clothing("pant", new Color(), Style.FANCY), new Clothing("pant", new Color(), Style.WORK)); shirts = new ClothingList("shirt", new Clothing("shirt", new Color(), Style.PLAIN), new Clothing("shirt", new Color(), Style.FANCY), new Clothing("shirt", new Color(), Style.WORK)); currentShirt = shirts.pick(1); currentPants = pants.pick(1); } private void enterASelectionManually() { shirts.listClothing(); System.out.println("Enter the number of the shirt that you want."); int selectedShirt = in.nextInt(); currentShirt = shirts.pick(selectedShirt); pants.listClothing(); System.out.println("Enter the number of the pants that you want."); int selectedPants = in.nextInt(); currentPants = pants.pick(selectedPants); displayCurrentSelection(); } private void displayCurrentSelection() { System.out.println("Current shirt: "+currentShirt); System.out.println("Current pants: "+currentPants); } private void pickRandomSelection() { currentShirt = shirts.pick(generator.nextInt(ClothingList.NUM_CLOTHES)+1); currentPants = pants.pick(generator.nextInt(ClothingList.NUM_CLOTHES)+1); displayCurrentSelection(); } }