Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

Describe the economic model that is proposed for the operation.

Answered: 1 week ago

Question

Which personal relationships influenced you the most?

Answered: 1 week ago

Question

What were your most important educational experiences?

Answered: 1 week ago

Question

How was your life influenced by those events?

Answered: 1 week ago