Question: JAVA Part 1. Develop a class Horse.java. The class should have the private variables: name, color, and birthYear. The class should have a default constructor

JAVA

Part 1. Develop a class Horse.java. The class should have the private variables: name, color, and birthYear. The class should have a default constructor and a non-default constructor which accepts values for name, color, and birthYear. You should have the appropriate getters and setters. The setter method for birthYear should not accept a value < 1988 or > 2018 (it will trap the user until a valid amount is entered by the user). The class should have a toString and an equals method.

Part 2. Develop a class RaceHorse.java which is a child of the class Horse.java. The class should have the private variables: races, and wins. The class should have a default constructor and a non-default constructor which accepts values for races, and wins. You should have the appropriate getters and setters. The setter method for races should not accept a value < 0 (it will trap the user until a valid amount is entered by the user). The setter method for races should not accept a value < 0 or greater than the number of wins (it will trap the user until a valid amount is entered by the user). The class should have a toString and an equals method.

Part 3. Develop a class BreedingHorse.java which is a child of the class Horse.java. The class should have the private variables: mother and father. The class should have a default constructor and a non-default constructor which accepts values for mother and father.. You should have the appropriate getters and setters. The class should have a toString and an equals method.

Part 4. Write a program DemoHorses.java that creates an array which will hold 6 instances of the class Horse. Using user input populate the array with 3 instances of the class RaceHorse and 3 instances of the class BreedingHorse. Have each instance call its toSting method and print the returned string to the screen.

Submit all 4 files.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!