Question: DemoHorses.Java public class DemoHorses { public static void main(String args[]) { Horse horse1 = new Horse(); RaceHorse horse2 = new RaceHorse(); horse1.setName(Old Paint); horse1.setColor(brown); horse1.setBirthYear(2009);
![DemoHorses.Java public class DemoHorses { public static void main(String args[]) {](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66fa6be39a599_65166fa6be30d908.jpg)
DemoHorses.Java
public class DemoHorses { public static void main(String args[]) { Horse horse1 = new Horse(); RaceHorse horse2 = new RaceHorse(); horse1.setName("Old Paint"); horse1.setColor("brown"); horse1.setBirthYear(2009); horse2.setName("Champion"); horse2.setColor("black"); horse2.setBirthYear(2011); horse2.setRaces(4); System.out.println(horse1.getName() + " is " + horse1.getColor() + " and was born in " + horse1.getBirthYear() + "."); System.out.println(horse2.getName() + " is " + horse2.getColor() + " and was born in " + horse2.getBirthYear() + "."); System.out.println(horse2.getName() + " has been in " + horse2.getRaces() + " races."); } }
---------------------------------------------------------------------------------------------------------------
Horse.Java
public class Horse { // Define the Horse class here }
-----------------------------------------------------------------------------------------------------------------
RaceHorse.java
public class RaceHorse { // Define the RaceHorse class here }
Programming Exercise 10-1 Instructions DemoHorses.java Horse.java RaceHorsejava+ 1 bublic class DemoHorses Create a class named Horse that contains the following data fields: public static void main(String args[]) 4 nane of type String Horse horse1new Horse RaceHorse horse2 new RaceHorse) horse1.setNae("Old Paint" horse1.setColor("brown"); horse1.setBirthYear (2009); horse2.setName("Champion") horse2.setColor("black"); horse2.setBirthYear (2011); horse2.setRaces(4); System.out.println(horse1.getName()"is "+ color- of type String birthYear of type int Include get and set methods for these fields 10 Next, create a subclass named RaceHorse, which contains an additional field, races (of 12 type tnt), that holds the number of races in 13 which the horse has competed and additional methods to get and set the new field 14 15 horse1.getcolor) and was born in "horse1.getBirthYear() 16 17 System.out.println(horse2.getNaneis " + horse2.getcolor) and was born in "horse2.getBirthYear() Grading System.out.println(horse2.getNane"has been in "+ Write your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade 18 19 20 21 horse2.getRaces() "races.") Once you are happy with your results, click the Submit button to record your score
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
