subject

Instrument information (derived classes) Given main() and the Instrument class, define a derived class, String Instrument, for string instruments. Ex. If the input is: Drums Zildjian 2015 2500 Guitar Gibson 2002 1200 19 the output is: the output is: Instrument Information: Name: Drums Manufacturer: Zildjian Year built: 2015 Cost: 2500 Instrument Information: Name: Guitar Manufacturer: Gibson Year built: 2002 Cost: 1200 Number of strings: 6 Number of frets: 19 File is marked as read only Current file: InstrumentInformation. java 1 import java. util. Scanner; public class Instrument Information { public static void main(String[] args) { Scanner scnr = new Scanner(System. in); Instrument my Instrument = new Instrument(); String Instrument myString Instrument = new StringInstrument(); String instrumentName, manufacturerName, string InstrumentName, stringManufacturer; int yearBuilt, cost, stringYearBuilt, stringCost, numStrings, numFrets; instrumentName = scnr. nextLine(); manufacturerName = scnr. nextLine(); yearBuilt = 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(); my Instrument. setName(instrumentName); my Instrument. setManufacturer (manufacturerName); my Instrument. setYearBuilt(yearBuilt); my Instrument. setCost(cost); my Instrument. printInfo(); myStringInstrument. setName(string InstrumentName); myString Instrument. setManufacturer(stringManufacturer) ; myString Instrument. setYearBuilt(stringYear Built); myString Instrument. setCost(stringCost); myString Instrument. setNumOfStrings (numStrings); myString Instrument. setNumOffrets(numFrets); myString Instrument. printInfo(); System. out. println(" System. out. println(" Number of strings: " + myString Instrument. getNumOfStrings()); Number of frets: " + myString Instrument. getNumOffrets()); 43 } File is marked as read only Current file: Instrument. java- public class Instrument { protected String instrumentName; protected String instrument Manufacturer; protected int yearBuilt, cost; public void setName(String userName) { instrumentName = userName; public String getName() { return instrumentName; public void setManufacturer(String userManufacturer) { instrumentManufacturer = userManufacturer; public String getManufacturer() { return instrumentManufacturer; public void setYear Built(int userYearBuilt) { yearBuilt = userYearBuilt; public int getYearBuilt() { return yearBuilt; public void setCost(int userCost) { cost = userCost; public int getCost() { return cost; public void printInfo() { System. out. println("Instrument Information: "); System. out. println(" Name: " + instrumentName); System. out. println(" Manufacturer: " + instrumentManufacturer); System. out. println(" Year built: " + yearBuilt); System. out. println(" Cost: " + cost); Current file: StringInstrument. java Load default template... 1 // TODO: Define a class: String Instrument that is derived from the Instrument class 2 public class String Instrument extends Instrument { // TODO: Declare private fields: numStrings, numFrets // TODO: Define mutator methods - // setNumOfStrings(), setNumOffrets() 9 // TODO: Define accessor methods - // getNumOfStrings(), getNumOffrets() 13

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 12:30, legend101xD
Animations and transitions are added from the
Answers: 1
image
Computers and Technology, 24.06.2019 05:30, MOONCHILDSUGA
If you combine two cells into one, what action are you performing? a.  adding a new row or column      b.  splitting the cells      c.  removing a new row or column      d.  merging the cells
Answers: 2
image
Computers and Technology, 25.06.2019 06:30, hayden5928
Which component is typically used as an amplifier a battery a transistor a microchip a diode
Answers: 1
image
Computers and Technology, 25.06.2019 08:20, jake2124
With technology, information is sent to users based on their previous inquiries, interests, or specifications.
Answers: 2
You know the right answer?
Instrument information (derived classes) Given main() and the Instrument class, define a derived cla...

Questions in other subjects:

Konu
English, 04.09.2020 09:01