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
Sergeeva-Olga [200]
3 years ago
13

Create a class named Horse that contains data fields for the name, color, and birth year. Include get and set methods for these

fields. Next, create a subclass named RaceHorse, which contains an additional field that holds the number of races in which the horse has competed and additional methods to get and set the new field. Write an application that demonstrates using objects of each class. Save the files as Horse.java, RaceHorse.java, and DemoHorses.java.
Computers and Technology
1 answer:
SashulF [63]3 years ago
8 0

Answer:

The code to this question can be given as:

Code:

import javax.swing.JOptionPane; //import package.

public class Horse //define class horse.

{

//define variable as private.

private String name;

private String color;

private String birthYear;

public void setName() //define function (setName)

{

name = JOptionPane.showInputDialog(null,"Please enter name of the horse:");

}

public void setColor() //define function (setColor)

{

color = JOptionPane.showInputDialog(null,"Please enter color of the horse:");

}

public void setYear() //define function (setColor)

{

birthYear = JOptionPane.showInputDialog(null,"Please enter birth year of the horse:");

}

public String getName() //define function (getName)

{

return name;

}

public String getColor() //define function (getColor

{

return color;

}

public String getYear() //define function (getYear)

{

return birthYear;

}

}

public class RaceHorse extends Horse //define class RaceHorse that inherit Horse

{

private String raceNum; //define variable as private

public void setRace() //define function (setRace)

{

raceNum = JOptionPane.showInputDialog(null,"Please enter number of the horse's races:");

}

public String getRace() //define function (getRace)

{

return raceNum;

}

}

public class DemoHorses //define class DemoHorses

{

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

{

Horse ob1 = new Horse(); //creating object of Horse

RaceHorse ob2 = new RaceHorse(); //creating object of RaceHorse

ob1.setName(); //calling functions

ob1.setColor();

ob1.setYear();

ob2.setRace();

//show messsage.

JOptionPane.showMessageDialog(null,"The name of the horse is " + ob1.getName() +

". The horse's color is " + ob1.getColor()+ ". It was born in " + ob1.getYear() +

". " + ob1.getName() + " has taken part in " + ob2.getRace() + " races");

}

}

Explanation:

In this code firstly we import the package that is used to create a message dialog with the given title and messageType. It is used to create a dialog with the options Yes, No and Cancel. This is used to show a question-message dialog and request for input from the user. Then we define 3 classes that are Horse.java, RaceHorse .java, and DemoHorses.java which name is already given in the question. In the first class i.e Horse. we declare variable as private and we use the get and set function. The set function sets the values and gets the function to get the values. Then we define second class i.e RaceHorse. In this class, we first inherit the Horse class. Then we define a variable as private and use the set and get function. Then we define another class i.e DemoHorse. In this class, we define the main method and call the above functions by creating their objects.

You might be interested in
Which statement is true about encoding in Python?
vovangra [49]

Answer:

In Python 3, strings are automatically encoded using Unicode.

Explanation:

i just tookthe test

6 0
3 years ago
What is a Windows feature that allows you to temporarily store text?
nata0808 [166]
This would be copy and paste.

When you select a text, you can use your keys CTRL and C to copy that same selected text. After this, you can use the paste feature by selecting CTRL and V. Doing this, your selected text will be copied and pasted to a certain location. 
3 0
3 years ago
Which of the following is a database concept that allows for storage and analysis for a dozen to billions of data points?
nydimaria [60]

Answer:

C) Storage

Explanation:

I am sure of it.

5 0
3 years ago
Explain about forensic tools?
Ganezh [65]

Answer:

 In the computer forensics, it basically examining the digital media by using the different types of specialist tools which is known as forensic tool.

It has the ability to acquiring the several evidence from the computer hard disk and by copying information, the data from the machine that can be procured and after that broke down for any data that is appropriate for the case.

There are different types of forensics tools that are:

  • SIFT (SANS Investigative Forensics Toolkit)
  • Volatility
  • Redline
  • Digitally forensics framework
  • COFEE

4 0
3 years ago
Consider an online shopping portal that allows a customer to browse and purchase different products. The products are arranged u
o-na [289]
Way too much to read bye
7 0
3 years ago
Read 2 more answers
Other questions:
  • Java languageThe cost to ship a package is a flat fee of 75 cents plus 25 cents per pound.1. Declare a constant named CENTS_PER_
    5·2 answers
  • Windows Live SkyDrive is an example of _____ storage.
    13·1 answer
  • Bit stream methods commonly use algorithm functions like the exclusive or operation (__________.
    11·1 answer
  • What is a custom information field that helps users to find a specific document?
    8·1 answer
  • Using the media as equipment for living. Explain how you would use some form of media to serve a purpose in your life—and what t
    6·2 answers
  • The main purpose of a constructor is to initialize the data members at the moment that an object is created. true or false?
    8·1 answer
  • Which of the following provides services to hosts on its network?
    9·1 answer
  • Read the scenario below, and then answer the question.
    13·1 answer
  • (Reverse number) Write a program that prompts the user to enter a four-digit inte- ger and displays the number in reverse order.
    9·1 answer
  • Which of the following lines of code would reduce the player’s gold by 100 coins?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!