Question: In java, Create a Farm class Included methods: Farm() Farm(int cows,int chickens, int sheep) setAnimals(int cows,int chickens, int sheep) getCows() getChickens() getSheep() addCows(int num) addChickens(int

In java,

Create a Farm class

Included methods:

Farm()

Farm(int cows,int chickens, int sheep)

setAnimals(int cows,int chickens, int sheep)

getCows()

getChickens()

getSheep()

addCows(int num)

addChickens(int num)

addSheep(int num)

removeCows(int num)

removeChickens(int num)

removeSheep(int num)

equals(Farm)

toString()

You will create a farm class that will create the farm object. This farm object will contain 3 ints that store the values of the number of cows, chickens, and sheep.

Make sure that you comment your code, only some methods are commented, you have to do the rest of the comments.

public class testFarm { public static void main (String[] args) { //make a new Farm object with no animals //set the farm to have 25 cows, 100 chickens, and 50 sheep //print your farm you should get "25 cows, 100 chickens, 50 sheep" //add 5 cows, 10 chickens, 12 sheep //print your farm you should get "30 cows, 110 chickens, 62 sheep" //remove 7 cows, 14 chickens, 0 sheep //print your farm you should get "23 cows, 96 chickens, 62 sheep" //create a second Farm object with 20 cows, 90 chickens and 60 sheep //use the ".equals" method you wrote to print if the two farms are equal, you should get false //add 3 cows, 6 chickens, 2 sheep to yor second farm ////use the ".equals" method you wrote to print if the two farms are equal, you should get true } }

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!