You must create two Java files. One is called LastNameFirstNameWeek6Prog.java, and the other is called Horse.java.
Ensure you include ALL files required to make your program compile and run. I would like to see your .java files only. 5%
Horse.java Class File
1. Create a new class called Horse that includes the functionality below
2. The new class has the attributes of:
name – Horse’s name, type String
age – age of Horse in years, type integer
height – height of Horse in meters, type double
color - type Horse’s color, type String
pureBlood - type boolean - true if Horse is pure blood, false if not
name – Horse’s name, type String
age – age of Horse in years, type integer
height – height of Horse in meters, type double
color - type Horse’s color, type String
pureBlood - type boolean - true if Horse is pure blood, false if not
3. Be sure your classes have a good set of accessor and mutator methods. Every member variable must have at least one independent accessor and one independent mutator.
Example:
public void setName(String name) mutator used to set name
public void seAge(int age) mutator used to set the age
//…. Add other mutator methods here
public String getName() accessor used to get name
public int getAge() accessor used to get age
//…. Add other accessor methods here
Ensure you use the “this” reference from within this class when referring to every instance variable or instance method of the current object. 45%
public void setName(String name) mutator used to set name
public void seAge(int age) mutator used to set the age
//…. Add other mutator methods here
public String getName() accessor used to get name
public int getAge() accessor used to get age
//…. Add other accessor methods here
Ensure you use the “this” reference from within this class when referring to every instance variable or instance method of the current object. 45%
LastNameFirstNameWeek6Prog.java Class File (Driver Program)
Write a driver program that reads in 3 animals of type Horse and prints out the name, age and height of all non pure blood Horse objects that are 4 or more years old. The following information should be read per Horse:
name
age
height
color
pureBlood
name
age
height
color
pureBlood
Conditional statements should be used to decide which Horse’s information should be printed.
Use accessor methods to check the age and pure blood status on each Horse. 45%
NOTE: Complete your activity and submit it by clicking on "Submit Assignment". 5%
Total Possible Points 100
Example output of your program
Example Run:
Enter the name of Horse1: chip
Enter the age of Horse1 in years: 1
Enter the height (in meters) of Horse1: 2
Enter the color of Horse1: grey
Is Horse1 a pure blood? true or false?: true
Enter the name of Horse2: munk
Enter the age of Horse2 in years: 4
Enter the height (in meters) of Horse2: 1.5
Enter the color of Horse2: white
Is Horse2 a pure blood? true or false?: true
Enter the name of Horse3: bluetooth
Enter the age of Horse3 in years: 5
Enter the height (in meters) of Horse3: 2.5
Enter the color of Horse3: red
Is Horse3 a pure blood? true or false?: false
Enter the name of Horse1: chip
Enter the age of Horse1 in years: 1
Enter the height (in meters) of Horse1: 2
Enter the color of Horse1: grey
Is Horse1 a pure blood? true or false?: true
Enter the name of Horse2: munk
Enter the age of Horse2 in years: 4
Enter the height (in meters) of Horse2: 1.5
Enter the color of Horse2: white
Is Horse2 a pure blood? true or false?: true
Enter the name of Horse3: bluetooth
Enter the age of Horse3 in years: 5
Enter the height (in meters) of Horse3: 2.5
Enter the color of Horse3: red
Is Horse3 a pure blood? true or false?: false
The non pure blood Horses over 4 years old are:
Name: bluetooth
Age: 5
Height: 2.5
Name: bluetooth
Age: 5
Height: 2.5