Question: Instructions: 1. Develop and test the Old MacDonald Farm classes as described in the Assignment section above. 2. Your lab assignment should have a zipped

 Instructions: 1. Develop and test the Old MacDonald Farm classes asdescribed in the Assignment section above. 2. Your lab assignment should havea zipped project that consists of the following 7 files: Animal.java -

Instructions: 1. Develop and test the Old MacDonald Farm classes as described in the Assignment section above. 2. Your lab assignment should have a zipped project that consists of the following 7 files: Animal.java - interface Chick.java, Cow.java, Dog.java - implementations of the Animal interface NamedCow.java - subclass of the Cow class Farm.java - collection of Animal objects OldMacDonald.java - testing class Background: In this lab, we will use the well-known song 'Old MacDonald Had a Farm' to learn about Inheritance and Polymorphism Old MacDonald had a farm and several types of animals. Every animal shared certain characteristics. They each had a type (such as cow, chick or dog) and each made a sound (moo, cheap or oink). An Interface defines those things required to be an animal on the farm. public interface Animal { public String getSound(); public String getType(); ) 1. Once we know what it takes to be an Animal, we can define new classes for the cow, chick and dog that implement the Animal interface. Here is a Cow class meeting the minimum requirements to be an Animal. public class cow implements Animal { private String myType; private String mySound; public Cow () { myType = "cow"; mySound = "moo"; } public String getSound() return mySound; } public String getType() { return myType; } 2. Implement classes for the chick and the dog. Also complete the test program below to verify your work so far: public class Tester { public static void main(String[] args) { Cow c = new Cow(); System.out.println( c.getType() + goes + c.getSound()); //

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!