Question
Can someone help me with this section? Am I writing one class under a java project? Or is it several classes under the same project?
Can someone help me with this section?
Am I writing one class under a java project? Or is it several classes under the same project?
4.2 Write the Java code to declare a new class Bee which is a subclass of Insect. The noise made by a Bee is "Buzz". 4.3 Write the Java code to declare a new abstract class Amphibian that implements the MakesNoise interface. 4.4 Write the Java code to declare a new class Frog which is a subclass of Amphibian. The noise made by a Frog is "Ribbet". 4.5 Modify the run() method of Main and add some Bees and Frogs to critters. Build your program and verify that it works correctly. Include all of your .java source code files in the zip archive that you submit for grading.
I have some things written out but the program does not run. Help please!
import java.util.ArrayList;
public interface MakeNoise {
public void MakeNoise();
void makeSound(); }
public abstract class Mammal implements MakeNoise {
}
public abstract class Insect implements MakeNoise {
}
public abstract class Amphibian implements MakeNoise {
}
public class Dog extends Mammal {
@Override public void makeNoise() { System.out.println("Barks"); } }
public class Cat extends Mammal {
@Override public void makeNoise() { System.out.println("Meows"); } }
public class Cricket extends Insect {
@Override public void makeNoise() { System.out.println("Chirps"); } }
public class Bee extends Insect {
@Override public void makeNoise() { System.out.println("Buzzes"); } }
public class Frog extends Amphibian {
@Override public void makeNoise() { System.out.println("Ribbets"); } }
public class Main {
public static void main(String[] args) { new Main().run(); }
public void run() { ArrayList
public void beNoisy(ArrayList
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started