Question: Please complete the tasks below (java). please leave comments explaining the basics. thanks Partner A completes Animal Class public class Animal { private String myType;
Please complete the tasks below (java). please leave comments explaining the basics. thanks
Partner A completes Animal Class
public class Animal {
private String myType; private String mySound;
public Animal() { /*your code here*/ }
public Animal(String t, String s) { /*your code here*/ }
public String getSound(){ /*your code here*/ } public String getType() { /*your code here*/ } }
Once we know what it takes to be an Animal, we can define new classes for the cow, chick and pig that extends from Animal class. Here is a Cow class meeting the minimum requirements to be an Animal.
Partner B complete Cow class
class Cow extends Animal { Cow(String type, String sound) { /*your code here*/ } public String getSound() { /*your code here*/ } public String getType() { /*your code here*/ } }
Implement classes for the chick Partner A and the pig Partner B.
Also complete the test program below to verify your work so far:
class TestFarm { public static void main(String[] args) { Cow c = new Cow("cow", "moo"); System.out.println( c.getType() + " goes " + c.getSound() ); < your code here > } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
