Question: This is My Main Class: static String instrument = null; static String choice = null; static Scanner input = new Scanner(System.in); static BrassFamily brass =

This is My Main Class:

static String instrument = null; static String choice = null; static Scanner input = new Scanner(System.in); static BrassFamily brass = new BrassFamily(instrument); static StringFamily string = new StringFamily(instrument); static WoodwindFamily woodwind = new WoodwindFamily(instrument); static PercussionFamily percussion = new PercussionFamily(instrument); //Begin Main Method @SuppressWarnings("empty-statement") public static void main(String[] args) {

int instrumentFam = 0;

System.out.println("Select one of the following instrument families: ");

System.out.println("1.Brass 2.String 3.Woodwind 4.Percussion " + "5.Display all instruments 6.Exit"); System.out.println("->: "); instrumentFam = input.nextInt();

switch (instrumentFam) { case 1:

int amount;

System.out.println("How many brass instruments would you like to enter? "); amount = input.nextInt();

String[] BrassNames = new String[amount];

for (int i = 0; i < amount; i++) { System.out.println("Enter instrument" + i); BrassNames[i] = input.next(); }

System.out.println("Display instruments? (Y for Yes, N for No)"); choice = input.next();

if (choice.equalsIgnoreCase("Y")) { for (int i = 0; i < amount; i++) { System.out.println(BrassNames[i]); } } else { System.out.println("Enter more instruments? "); } break; case 2: //String instruments

System.out.println("How many string instruments would you like to enter? "); amount = input.nextInt();

String[] StringNames = new String[amount];

for (int i = 0; i < amount; i++) { System.out.println("Enter instrument" + i); StringNames[i] = input.next(); }

System.out.println("Display instruments? (Y for Yes, N for No)"); choice = input.next();

if (choice.equalsIgnoreCase("Y")) { for (int i = 0; i < amount; i++) { System.out.println(StringNames[i]); } } else { System.out.println("Enter more instruments? "); } break; case 3: //Woodwind instruments

System.out.println("How many woodwind instruments would you like to enter? "); amount = input.nextInt();

String[] WoodwindNames = new String[amount];

for (int i = 0; i < amount; i++) { System.out.println("Enter instrument" + i); WoodwindNames[i] = input.next(); }

System.out.println("Display instruments? (Y for Yes, N for No)"); choice = input.next();

if (choice.equalsIgnoreCase("Y")) { for (int i = 1; i < amount; i++) { } } else { System.out.println("Enter more instruments? "); } break; case 4: //Percusssion instruments

System.out.println("How many percussion instruments would you like to enter? "); amount = input.nextInt();

String[] PercussionNames = new String[amount];

for (int i = 0; i < amount; i++) { System.out.println("Enter instrument" + i); PercussionNames[i] = input.next(); }

System.out.println("Display instruments? (Y for Yes, N for No)"); choice = input.next();

if (choice.equalsIgnoreCase("Y")) { for (int i = 0; i < amount; i++) { System.out.println(PercussionNames[i]); } } else { System.out.println("Enter more instruments? "); } break; case 5://Display all instruments displayInstruments(); break; case 6://Exit Program GoodBye(); } } /** * Method GoodBye: used to say goodbye. Common for several calls */ private static void GoodBye() { System.out.print("Enter more instrucments? (Y for Yes, N for No)->: "); choice = input.next(); if (choice.equalsIgnoreCase("n")) { System.out.println("Goodbye"); System.exit(0); } } /** * Method displayInstruments: Used to display results */ private static void displayInstruments() {

brass.howToPlay(); string.howToPlay(); woodwind.howToPlay(); percussion.howToPlay();

} }//End Main Method

And this is the correct structure it's supposed to be in. Can someone jsut clean mine up I have been looking at it so long Im confusing myself & im having trouble on how to call the display and goodbye methods.

{

static String instrument = null; static String iName; static String cont = null;

/** * New Scanner object */ static Scanner sc = new Scanner(System.in);

/** * New Subclass objects. Brass is complete. Woodwinds, Strings, and Percussion * must be added */ static Brass_Skeleton brass = new Brass_Skeleton(instrument);

//Begin Main Method public static void main(String[] args) {

/*Variable Declarations*/ int choice; String dispInt;

System.out.println("Select one of the following instrument families:"); do { System.out.print("1. Brass 2. String 3. Woodwind 4. Percussion 5. Display all instruments 6. Exit ->: "); choice = sc.nextInt(); switch (choice) { case 1: /*set iName = to the type of instrument. Example: iNmae = "brass"*/ /*call a method within the main class to enter the instrucment using iName*/ break; /*add case blocks for addition instrument types as required*/ /*add case block to call display instruments method*/ /*add exit and default case bloks*/ } System.out.print("Display instrucments? (Y for Yes, N for No)->: "); dispInt = sc.next(); if (dispInt.equalsIgnoreCase("y")) { /*call display instruments method*/ /*call goodbye method*/ } else { /*call goodbye method*/ } } while (cont.equalsIgnoreCase("Y")); } //End Main Method

/** * Method GoodBye: used to say goodbye. Common for several calls */ private static void GoodBye() { System.out.print("Enter more instrucments? (Y for Yes, N for No)->: "); cont = sc.next(); if (cont.equalsIgnoreCase("n")) { System.out.println("Goodbye"); System.exit(0); } }

/** * Method enterInst: Used to set instruments * * @param instName */ private static void enterInst(/*declare variable to receive instrument type name*/) { int numInts; System.out.printf("How many %s instruments would you like to enter?->: ", /*instrument type name variable*/); numInts = sc.nextInt(); /*Begin for loop to enter instruments.*/ for (int i = 0; i < numInts; i++) { System.out.printf("Enter instrument #%d->: ", i + 1); instrument = sc.next(); switch (/*instrument type name variable*/) { case "brass": brass./*call public set method in brass subclass while sending instrument entered*/(instrument); break; /*add case blocks for additional instrument types. will be like brass above*/ /*add default block*/ } } }

/** * Method displayInstruments: Used to display results */ private static void displayInstruments() {

brass./*call how to play overloaded method in brass subclass*/ /*add calls to other three types of instruments. will be like brass above*/

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!