Question: Java Programming II Homework 6 Create a class to represent a Farm object containing instances of the Animal objects Farm View javadoc for Animal and

Java Programming II Homework 6

Create a class to represent a Farm object containing instances of the Animal objects

Farm

View javadoc for Animal and Farm classes https://bit.ly/2X6yxzw

- animals : Animal [ ] - farmName : String - numAnimals : int //calculated controlled variable no setter + Farm() //default 10 animals + Farm(String) //default 10 animals + Farm(int) //size of array + Farm(String, int) + addAnimal(Animal) : void //use the next available slot to add the Animal, resize the array if necessary + getFarmName() : String + setFarmName(String) : void + getAnimal(int) : Animal //return null if index is invalid + getNumAnimals() : int //notice no setter this is a controlled variable + getFirstAnimal() : Animal + getLastAnimal() : Animal + getAnimals() : Animal[ ] + printAllDetails() : void // prints Farm attributes followed by Animal attributes as formatted below : // "FarmName: %20s | Number of Animals: %4d | Farm Size: %4d " // "Name: %20s | Year of Birth: %4d | Weight: %10.2f | Gender: %c " + removeAnimal(int) : Animal + removeAllAnimals() : void + getTotalWeightOfAllAnimals() : double + getAverageWeightOfAllAnimals() : double + getNumberOfAnimalsAboveWeight(double) : int + getNumberOfAnimalsBelowWeight(double) : int + increaseWeightOfAllAnimals() : void + increaseWeightOfAllAnimals(double) : void 

View javadoc for Animal and Farm classes https://bit.ly/2X6yxzw

Submission Instructions

'Main.java', 'Animal.java', and 'Farm.java'

Compile command: javac Main.java Animal.java Farm.java -Xlint:all -encoding utf-8

We will use this command to compile your code

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!