Question
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)
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.
Java*
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started