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
A cracked tone ring will often cause what type of problem?
emmainna [20.7K]
A cracked tone ring will often cause, False ABS actuation at low speed.
3 0
3 years ago
A technician is troubleshooting a Windows system in which an application works properly when the computer is booted in Safe Mode
sweet-ann [11.9K]

Answer:

yoooo nba BAD BAD

Explanation:

3 0
3 years ago
How are the current and resistance related when the voltage of a circuit is constant?
andreev551 [17]
Since resistance and current are inversely proportional, when the resistance doubles, the current is cut in half.
5 0
2 years ago
Read 2 more answers
Develop a C program that calculates the final score and the average score for a student from his/her (1)class participation, (2)
White raven [17]

Answer:

Following are the code to the given question:

#include<iostream>//defining header file

using namespace std;

int main()//defining main method

{

float clspat,test,asst,exam,practice,total,average;//defining floating variable

char name[100];//defining char variable to input value

cout<<"Enter Name of Student: ";//print message

cin>>name; //input value

cout<<"Enter scores in following scoring items between 0 and 100:"<<"\n";//print message

cout<<"Enter class participation score: ";//print message

cin>>clspat;//input value

cout<<"Enter test score: ";//print message

cin>>test;//input value

cout<<"Enter assignment score: ";//print message

cin>>asst;//input value

cout<<"Enter exam score: ";//print message

cin>>exam;//input value

cout<<"Enter practice score: ";//print message

cin>>practice;//input value

total=clspat+test+asst+exam+practice;//calculating total value

average=total/5;//calculating average value

cout<<endl<<"SCORE CARD OF "<<name<<"\n"<<"-----------------------"<<"\n";//print value with message

cout<<"Total score: "<<total<<"\n";//print message with value

cout<<"Average score: "<<average; //print message with value

}

Output:

please find the attached file.

Explanation:

In this code, the floating-point variable is declared, which is used for input value from the user-end and after input the floating-point value it uses the "total, average" variable to calculate its respective values and store its value with init, after storing the value into the variable it uses the print method to print its values.

5 0
3 years ago
What are examples of scanning devices?
eimsori [14]

Here the examples of scanning devices :

  • Drum Scanner.
  • Handheld Scanner.
  • Flatbed Scanner.
  • Optical Character Recognition.
  • Magnetic Ink Character Recognition.
  • Image Scanner.

<h3>What is meant by scanning ?</h3>
  • A text is scanned quickly in order to find a specific piece of information. In daily life, scanning is regularly used for tasks like looking up a word in a dictionary or finding a friend's name in your phone's contacts list.
  • Scanners may basically be divided into three categories. These consist of network scanning, port scanning, and vulnerability scanning.
  • There are three different types of scanners: portable scanners, flatbed scanners, and drum scanners. While flatbed scanners are commonly used in offices and classrooms, drum scanners are mainly used in the publishing industry to print high-quality pictures.
  • Three processes make up the basic scanning process: scan, register, and detail.

Learn more about scanning refer to :

brainly.com/question/25106178

#SPJ4

4 0
11 months ago
Other questions:
  • A collection of related files that serves as a foundation for retrieving information is a: byte
    12·1 answer
  • A word object in an excel worksheet to activate the word features
    9·1 answer
  • How are Action Buttons different than hyperlinks?
    8·1 answer
  • I need help. I wanna help a friend by giving him my powerpoint but I dont want him to steal my work. Is their anyway to restrict
    8·1 answer
  • You've been given a network of 130.0.0.0 /16. you need to divide it into four VLSM subnets as follows:
    8·1 answer
  • Which of the following describes the purpose of project management? planning and organizing resources to meet a goal arranging t
    15·1 answer
  • Complete the sentence.
    8·1 answer
  • Widow in respect to word processing ​
    15·1 answer
  • Read each of the following statements about Computer Science and explain why you think that statement is true.
    9·1 answer
  • HELP 100 points
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!