Question: PLEASE WRITE THIS CODE WITH JAVA!!! The system should have three classes: Instrument, Keyboard and Guitar. Instrument is the parent of other classes. Instrument defines

PLEASE WRITE THIS CODE WITH JAVA!!!

The system should have three classes: Instrument, Keyboard and Guitar. Instrument is the parent of other classes.

Instrument defines certain fields, such as year(int), condition(string) and brand (string). These variables have their setters and getters defined.

Keyboard, has an extra field of numberOfKeys(int).

Guitar has an extra field named numberOfStrings which can be 4,6 or 7. Any other values must be rejected. Use exception handling to prevent other values.

Once you create these classes write your test class with main method. Create Keyboard and Guitar objects, receive the values from the user and use exception handling for input mismatch. Assign them into an Instrument array of 2 elements. Then use a for loop to display their information.

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!