Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What's up Chegg? I need your help on this weeks Java programming task. I submitted my code for my task this week and I didn't

What's up Chegg? I need your help on this weeks Java programming task. I submitted my code for my task this week and I didn't do all that well got a 67. That said since many of us didn't do all that well for the task, the instructor gave us SKELETON CODES or S-CODES that he would like us to follow to complete this weeks task. Chegg can you help me with setting up the S-CODES for this task? The book for the class is Introduction to Java Programming, Comprehensive Version Y. Daniel Liang & Prentice Hall 11th Edition / 2018. We are currently working in Chapter 13. but this task covers all learned from week 1 through week 13.

Task for this week Write a program that will compile a list of instruments from different instrument families. A family of musical Instruments is a grouping of several different but related sizes or types of instruments. Ref: https://en.wikipedia.org/wiki/Family_(musical_instruments) Some commonly recognized families are:

Brass Family - A brass instrument is a musical instrument that produces sound by sympatheticvibration of air in a tubular resonator in sympathy with the vibration of the player's lips.

Ref: https://en.wikipedia.org/wiki/Brass_instrument

Strings Family - String instruments, stringed instruments, or chordophones are musicalinstruments that produce sound from vibrating strings.

Ref: https://en.wikipedia.org/wiki/String_instrument

Woodwind Family - Woodwind instruments are a family of musical instruments within the moregeneral category of wind instruments. There are two main types of woodwind instruments:flutes and reed instruments (otherwise called reed pipes). What differentiates theseinstruments from other wind instruments is the way in which they produce their sound.

Ref: https://en.wikipedia.org/wiki/Woodwind_instrument

Percussion Family - A percussion instrument is a musical instrument that is sounded by beingstruck or scraped by a beater (including attached or enclosed beaters or rattles); struck, scrapedor rubbed by hand; or struck against another similar instrument.

Ref: https://en.wikipedia.org/wiki/Percussion_instrument

Constraints

Limit the number of families to the list aboveUse one separate (external to the main class) abstractsuper class: InstrumentUse three separate (external to the main class) abstract subclasses that extend Instrument:oBlownInstrumentoFingeredoStruckUse four separate (external to the main class) subclasses (families) that extend the appropriate three aboveoBrassoStringsoWoodwindoPercussion

Requirements

Display the menu shown in the example output belowRequest the number of instruments to be entered

All instruments should be placed into an array (you can use one array per family or one array for all entered) so they may be displayed

Use set and get methods where appropriateImplement a loop that will allow the user to enter more instruments

Use exception handling and validation where appropriate

This assignment will use coding principles learned from week 1 through 13

Hints

Make sure you use Java coding conventions

Expected Output

Below is a sample run where instruments are entered for each family. User input is in BOLD

Select one of the following instrument families:

1.Brass

2.String

3.Woodwind

4.Percussion

5.Display all instruments

6.Exit

->: 1

How many brass instruments would you like to enter? ->: 3

Enter instrument #1->: bugle

Enter instrument #2->: trumpet

Enter instrument #3->: tuba

Display instruments?

(Y for Yes, N for No)->: n

Enter more instruments?

(Y for Yes, N for No)->: y

1.Brass

2.String

3.Woodwind

4.Percussion

5.Display all instruments

6.Exit

->: 2

How many string instruments would you like to enter? ->: 2

Enter instrument #1->: guitar

Enter instrument #2->: harp

Display instruments?

(Y for Yes, N for No)->: n

Enter more instruments?

(Y for Yes, N for No)->: y

1.Brass

2.String

3.Woodwind

4.Percussion

5.Display all instruments

6.Exit

->: 3

How many wood wind instruments would you like to enter? ->: 2

Enter instrument #1->: clarinet

Enter instrument #2->: oboe

Display instruments?

(Y for Yes, N for No)->: n

Enter more instruments?

(Y for Yes, N for No)->: y

1.Brass

2.String

3.Woodwind

4.Percussion

5.Display all instruments

6.Exit

->: 4

How many percussion instruments would you like to enter? ->: 2

Enter instrument #1->: drum

Enter instrument #2->: marimba

Display instruments?

(Y for Yes, N for No)->: n

Enter more instruments?

(Y for Yes, N for No)->: y

1.Brass

2.String

3.Woodwind

4.Percussion

5.Display all instruments

6.Exit

->: 5

The bugle is a brass instrument and is played by mouth.

The trumpet is a brass instrument and is played by mouth.

The tuba is a brass instrument and is played by mouth.

The clarinet is a woodwind instrument and is played by mouth.

The oboe is a woodwind instrument and is played by mouth.

The guitar is a string instrument and is played with fingers.

The harp is a string instrument and is played with fingers.

The drum is a percussion instrument and is struck.

The marimba is a percussion instrument and is struck.

Enter more instruments?

(Y for Yes, N for No)->: n

Goodbye

***********************************************************************************************************************************************************************************

Below in BOLD are the SKELETON CODES our instructor wants us to use to complete the code.

package week13_skeleton;

/** * @Course: SDEV 250 ~ Java Programming I * @Author Name: Steven Hickey * @Assignment Name: week13_skeleton * @Date: Nov 24, 2016 * @Description: Week 13 Skeleton Code * http://examples.javacodegeeks.com/java-basics/java-abstract-class-example/ * ATTENTION (read below) * Missing subclasses: * Create abstract classes for: * Fingered Instruments * Struck Instruments * (Blown will cover two of the classes, Brass and Woodwind) * Create classes that extend their appropriate abstract classes for: * Percussion * Stringed * Woodwinds */ //Imports import java.util.Scanner; //Begin Class Week13_Skeleton

public class Week13_Skeleton {

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*/

} } //End Class Week13_Skeleton

********************************************************************************************************************************************************************************************

package week13_skeleton;

/** * @Course: SDEV 250 ~ Java Programming I * @Author Name: Steven Hickey * @Assignment Name: week13_skeleton * @Date: Nov 24, 2016 * @Subclass Instrument_Skeleton Description: */ //Imports //Begin Subclass Instrument_Skeleton abstract class Instrument_Skeleton {

protected String name;

abstract public void howToPlay(); } //End Subclass Instrument_Skeleton

***********************************************************************************************************************************************************************************************

package week13_skeleton;

/** * @Course: SDEV 250 ~ Java Programming I * @Author Name: Steven Hickey * @Assignment Name: week13_skeleton * @Date: Nov 24, 2016 * @Subclass Brass_Skeleton Description: Brass class */ //Imports import java.util.ArrayList; //Begin Subclass Brass_Skeleton

class Brass_Skeleton extends BlownInstrument_Skeleton {

/*declare a local ArrayList of type String to hold entered instruments*/

Brass_Skeleton(/*declare String variable for brass instrument*/) { /*declare super with no arguments*/ /*declare this name and set equal to variable declared for brass instrument*/ this.blown = " is played by mouth."; }

public void setInts(String bI) { /*arraylist name from above*/.add(bI); }

public ArrayList getInts() { return /*arraylist name from above*/; }

@Override public void howToPlay() { for (String array : getInts()) { System.out.println("The " + array + " is a brass instrument and" + blown); } } } //End Subclass Brass_Skeleton

*************************************************************************************************************************************************************************************************

package week13_skeleton;

/** * @Course: SDEV 250 ~ Java Programming I * @Author Name: Steven Hickey * @Assignment Name: week13_skeleton * @Date: Nov 24, 2016 * @Subclass BlownInstrument Description: Abstract Skeleton for blown instruments */ //Imports

//Begin Subclass BlownInstrument_Skeleton abstract class BlownInstrument_Skeleton extends Instrument_Skeleton{ protected String blown; } //End Subclass BlownInstrument_Skeleton

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions