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
larisa [96]
3 years ago
8

Create a class named Horse that contains the following data fields: name - of type String color - of type String birthYear - of

type int Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field, races (of type int), that holds the number of races in which the horse has competed and additional methods to get and set the new field.
Computers and Technology
1 answer:
kozerog [31]3 years ago
6 0

Answer:

The program to this question can be given as:

Program:

class Horse   //define class Horse

{  

private String name;   //define variables.

private String color;  

private int birthYear;  

//define set method.

public void setName(String name)  

{  

this.name = name; //set value of name.

}

public void setColor(String color)  

{  

this.color = color; //set value of color.  

}  

public void setBirthYear(int birthYear)

{  

this.birthYear = birthYear;  //set value of birthYear

}  

//define get method.

public String getName()  

{  

return name;  //return name.

}  

public String getColor()

{  

return color;  //return color.

}  

public int getBirthYear()

{  

return birthYear;  //return birthYear.

}  

}

class RaceHorse extends Horse     //define class RaceHorse  

{

private String raceNum;            //define variable.

public void setRace(String raceNum)    //define set method.

{

 this.raceNum=raceNum;      //set value of raceNum.

}

public String getRace()

{

 return raceNum;   //return raceNum

}

}

public class Main      //define main class.

{

public static void main(String[] args) //define main method.

{

 Horse ob= new Horse();  //creating class objects.

 RaceHorse ob1 = new RaceHorse();

 ob.setName("XXX");       //calling function

 ob.setColor("BLACK");

 ob.setBirthYear(2008);

 ob1.setRace("Five hundred meter");

 //print return values.

       System.out.println("The name of the horse is " + ob.getName()+"." +"\n"+  

   "The horse's color is " + ob.getColor()+"."+"\n"+ "It was born in " + ob.getBirthYear() +  

   "."+"\n"+ ob.getName()+" has taken part in " + ob1.getRace() + " races.");

   

}

}

Output:

The name of the horse is XXX.

The horse's color is BLACK.

It was born in 2008.

XXX has taken part in Five hundred meter races.

Explanation:

In the above program firstly we declare the class that is Horse in this class we define a variable that name is already given in the question which are name, color, and birthYear. In these variables are name and color datatype is string and the birthYear datatype is an integer because it stores the number. Then we use the get and set function in the get function we return all variable value. and in the set function, we set the values of the variable by this keyword. Then we declare another class that is RaceHorse this class inherit Horse class. In the RaceHorse class, we define a variable that is raceNum that's data type is a string in this class we also used the get and set function. Then we declare the main class in the main class we define the main method in the main method we create the above class object and call the set and get function and print the values of the function.

You might be interested in
When should you integrate technology?​
earnstyle [38]
Nolur acil lütfen yalvarırım yalvarırım lütfen yalvarırım when should you integrate technology?
5 0
3 years ago
Read 2 more answers
Free points ♡
forsale [732]

Answer:

dax and dear god, also my heart hurts

Explanation:

they are great so is he u should listen to him

4 0
3 years ago
Read 2 more answers
in Google, how should you phrase your search if you want to exclude a certain word from your results(for example,"chocolate")?
dusya [7]
I found this:
ou can exclude words from your search by using the - operator; any word in your query preceded by the - sign is automatically excluded from the search results. Remember to always include a space before the - sign, and none after

I found it here:
http://www.informit.com/articles/article.aspx?p=675274&seqNum=3
3 0
3 years ago
To remove the field list when working on a report in Design view, tap or click the ____ button on the REPORT DESIGN TOOLS DESIGN
Rudiy27

Answer:

The correct answer to the following question will be "Remove".

Explanation:

A report consists of information taken from tables or queries and information stored in the design of the report such as names, heading, and graphics. Also known as the source of the report are tables or queries that provide the underlying data.

The majority of reporting tools provide only a standard report layout where the report developer may not construct a custom layout with elements positioned in certain areas.

And, If we want to remove any field while working in Design view on a report then we have to click on the remove button for such tasks,

Therefore, the Remove button is the correct answer.

6 0
3 years ago
What is meant by Program Memory is paged?
atroni [7]

Answer:

Program memory is paged, this statement is defined as in a computer system paged memory is the process of allocation of memory and storing a portion of a process of execution. Page is a unit of logical memory in a program. It follows the process of paging, as it is a method of writing an information and reading the output from the storage drive. The main advantage of this process is that it become easy to swap because everything is the same size.

7 0
3 years ago
Other questions:
  • A Hierarchy Custom Setting stores a specific URL for each profile in Salesforce. Which statement can a developer use to retrieve
    5·1 answer
  • Identifying what you will need to review takes place during?
    8·2 answers
  • You work administrative assistant in an engineering firm. A co-worker constantly makes fun of the engineers by whispering commen
    13·1 answer
  • What is responsible for making an axle spin in an electric motor? an outside power source attached to a magnet an outside power
    6·2 answers
  • Does anyone have the problem where you try to watch a video to get your answer but it brings up a thing asking your gender to ma
    6·1 answer
  • Online databases allow you access to material you may not be able to find when using popular search engines like Google. Select
    10·1 answer
  • As defined by the National Institute of Standards and Technology​ (NIST), "________ is a model for enabling​ ubiquitous, conveni
    11·1 answer
  • What is one similarity between compiled and interpreted programming languages? (5 points)
    6·1 answer
  • Your company decided to upgrade the older office Ethernet network and needs the fastest speed possible but has decided against f
    8·1 answer
  • Discussion Topic
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!