Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java please Given main0 and the Instrument class, define a derived class, StringInstrument, with methods to set and get private fields of the following

in java please image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Given main0 and the Instrument class, define a derived class, StringInstrument, with methods to set and get private fields of the following types: - int to store the number of strings - int to store the number of frets - boolean to store whether the instrument is bowed Ex. If the input is: Druman zildjian 2015 2500 Guitar Gibson 2002 1200 6 19 false the output is: Inatrument Information: Name: Drums Manufacturert zildjian Year built: 2015 Cost: 2500 Insteument intormation: Names Gultar Manufacturert Gibson Year bullt: 2002 Coelt: 1200 Nueber of atrings: 6 Number of fretsi 19 In bowedt false String instrumentName, manufacturerName, stringInstrumentName, stringManufacturer; int yearBuilt, cost, stringYearBuilt, stringCost, numStrings, numFrets; boolean bowed; instrumentName = scnr. nextLine() manufacturerName = scnr, nextLine(); 16171819202122232425262728293031yearBuilt=scnr.nextInt();Scnr.nextLine();cost=scnr.nextInt();scnr.nextLine();stringInstrumentName=scnr.nextLine();stringManufacturer=scnr.nextLine();stringYearBuilt=scnr.nextInt();stringCost=scnr.nextInt();numStrings=scnr.nextInt();numFrets=scnr.nextInt();bowed=scnr.nextBoolean();myInstrument.setName(instrumentName);myInstrument.setManufacturer(manufacturerName);myInstrument.setYearBuilt(yearBuilt);mvInstrument.set(ost(cost): myInstrument.printInfo(); myStringInstrument. setName(stringInstrument Name); myStringInstrument. setManufacturer(stringManufacturer); myStringInstrument. setYearBuilt(stringYearBuilt); myStringInstrument. setCost(stringCost); myStringInstrument. setNum0fStrings(numStrings); I myStringInstrument. setNum0fFrets(numFrets); myStringInstrument. setIsBowed(bowed); myStringInstrument,printInfo(); System.out.println(" Number of strings: " + myStringInstrument.getNumOfStrings( )); System.out.println(" Number of frets: " + myStringInstrument. getNumOffrets()); System,out.println(" Is bowed: " + myStringInstrument.getIsBowed( )); File is marked as read only Current file: Instrument.java - File is marked as read only Current file: Instrument.java - Current file: Instrument.java 1 // TOD0: Define a class: StringInstrument that is derived from the Instrument class 2 public class StringInstrument extends Instrument \{ /I TODO: Declare private fields I/ TODO: Define mutator methods - II setNumOfStrings(), setNumOfFrets(), setIsBowed() 1 I/ TODO: Define accessor methods - II getNumOfStrings(), getNumOffrets(), getIsBowed() \}

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions