1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
erastovalidia [21]
2 years ago
7

In this exercise, you are going to build a hierarchy to create instrument objects. We are going to create part of the orchestra

using three classes, Instrument, Wind, and Strings. Note that the Strings class has a name very close to the String class, so be careful with your naming convention!We need to save the following characteristics:Name and family should be saved for all instrumentsWe need to specify whether a strings instrument uses a bowWe need to specify whether a wind instrument uses a reedBuild the classes out with getters and setters for all classes. Only the superclass needs a toString and the toString should print like this:Violin is a member of the String family.Your constructors should be set up to match the objects created in the InstrumentTester class.These are the files givenpublic class InstrumentTester{public static void main(String[] args){/*** Don't Change This Tester Class!** When you are finished, this should run without error.*/Wind tuba = new Wind("Tuba", "Brass", false);Wind clarinet = new Wind("Clarinet", "Woodwind", true); Strings violin = new Strings("Violin", true);Strings harp = new Strings("Harp", false); System.out.println(tuba);System.out.println(clarinet); System.out.println(violin);System.out.println(harp);}}////////////////////////////public class Wind extends Instrument{}///////////////////////////public class Strings extends Instrument{ }/////////////////////////public class Instrument{ }
Computers and Technology
1 answer:
creativ13 [48]2 years ago
3 0

Answer:

Explanation:

The following code is written in Java and creates the classes, variables, and methods as requested. The String objects created are not being passed a family string argument in this question, therefore I created two constructors for the String class where the second constructor has a default value of String for family.

package sample;

class InstrumentTester {

   public static void main(String[] args) {

       /*** Don't Change This Tester Class!** When you are finished, this should run without error.*/

       Wind tuba = new Wind("Tuba", "Brass", false);

       Wind clarinet = new Wind("Clarinet", "Woodwind", true);

       Strings violin = new Strings("Violin", true);

       Strings harp = new Strings("Harp", false);

       System.out.println(tuba);

       System.out.println(clarinet);

       System.out.println(violin);

       System.out.println(harp);

   }

}

class Wind extends Instrument {

   boolean usesReef;

   public Wind(String name, String family, boolean usesReef) {

       this.setName(name);

       this.setFamily(family);

       this.usesReef = usesReef;

   }

   public boolean isUsesReef() {

       return usesReef;

   }

   public void setUsesReef(boolean usesReef) {

       this.usesReef = usesReef;

   }

}

class Strings extends Instrument{

   boolean usesBow;

   public Strings (String name, String family, boolean usesBow) {

       this.setName(name);

       this.setFamily(family);

       this.usesBow = usesBow;

   }

   public Strings (String name, boolean usesBow) {

       this.setName(name);

       this.setFamily("String");

       this.usesBow = usesBow;

   }

   public boolean isUsesBow() {

       return usesBow;

   }

   public void setUsesBow(boolean usesBow) {

       this.usesBow = usesBow;

   }

}

class Instrument{

   private String family;

   private String name;

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public String getFamily() {

       return family;

   }

   public void setFamily(String family) {

       this.family = family;

   }

   public String toString () {

       System.out.println(this.getName() + " is a member of the " + this.getFamily() + " family.");

       return null;

   }

}

You might be interested in
An executive in a computer software firm works with his office door closed. At the same time every hour he opens the door to see
Masja [62]

Answer: (A) Fixed interval

Explanation:

 The fixed interval schedule is the type of schedule of the reinforcement in the operand conditioning in which the the initial response are rewarded by some specific amount of the time.

The main issue with the fixed interval schedule is that the people have to wait until the reinforcement schedule get occur and start their actual response of interval. This type of reinforcement schedule occur as the output value does not posses constant value all the time.

Therefore, Option (A) is correct.

4 0
3 years ago
Who is known as the father of computer? ​
juin [17]

Answer:

Charles babbage ok my boy

8 0
3 years ago
Read 2 more answers
5) How is the operating system on a desk top computer different from the operating system on a smart phone?​
lesya692 [45]
The difference is that system on a desk top preforms all the basic tasks like file management, memory management handling input and output and controlling peripheral devices such ad disk and printers where as some smart phone work on specific hardware
6 0
3 years ago
Which of the following tasks requires you to use the Tabs option?
LenaWriter [7]
In Microsoft Word, the TAB button shifts the text to the right. For example, starting a new paragraph, the TAB button indents the beginning.<span />
3 0
2 years ago
A(n) _____ of an class is where the services or behaviors of the class is defined. (Points : 6) operation
k0ka [10]

Answer:

Operation the correct answer for the given question.

Explanation:

An operation is a template that is used as a template parameter .An operation defined the services and behaviors of the class .The operation is directly invoked on instance .

Attribute define the property of an entity it is not defined the services and behaviors of the class. so this option is incorrect.

Class is the class of variable of method it is not defined the services and behaviors of the class  so this option is incorrect.

Object are the rub time entity .object are used access the property of a class it is not defined the services and behaviors of the class  so this option is incorrect.

Abstract class is the class which have not full implementation of all the method .it is not defined the services and behaviors of the class  so this option is incorrect.

So the correct answer is operation.

6 0
3 years ago
Other questions:
  • The open items on your computer are displayed here. menu bar open bar taskbar toolbar
    15·2 answers
  • When powering up the computer, the initial program loading and start-up is performed by using a ______________ program that is b
    14·1 answer
  • Once the data center routes to the destination server that hosts the website, whats the next step in the internet process?
    10·1 answer
  • There is no way to see how another project in Scratch was made.<br><br> True<br> False
    11·1 answer
  • What is the atomic number of neonWhat do the following results from the TEST FOR LIFE tab indicate about the sample
    15·1 answer
  • How many bytes are there in 256 Kbytes?
    6·1 answer
  • hãy lựa chọn một doanh nghiệp kinh doanh theo loại hình siêu thị việt nam em hãy tìm hiểu doanh nghiệp và thực hiện theo yêu cầu
    10·1 answer
  • How do I convert years to days on Python. For example, if I were to enter 3 years it should output "You are 1095 days old".
    5·1 answer
  • Pls someone help me with these four questions
    8·1 answer
  • In the bremmer article, the author states that _________ translates into greater risks.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!