Question
Complete Constructors For Both The Basilisk And Bigfoot Subclasses The Constructor Should Take Parameters For Name, Weight And Species Name And Call The Superclass Constructor
Complete Constructors For Both The Basilisk And Bigfoot Subclasses The Constructor Should Take Parameters For Name, Weight And Species Name And Call The Superclass Constructor With Those Values. Implement The Abstract MakeNoise() Method From MagicBeast In The Basilisk And Bigfoot Subclasses.
Tasks:
- Complete constructors for both theBasiliskandBigfootsubclasses
- The constructor should take parameters forname, weightandspecies nameand call the superclass constructor with those values.
- Implement the abstractmakeNoise()method from MagicBeastin theBasiliskandBigfootsubclasses.The Basilisk implementation should return "Squawk", and the Bigfoot implementation should return "Rawr".
- Complete theaddBeastmethod inCryptoManagerso they properly add MagicBeasts from the ArrayList.
For testing, the Runner makes a series of prompts for data (name, then weight, then species name) and creates a MagicBeast using that data. The MagicBeast subclass used depends on the value ofspecies name(Basilisk if entered species name is "Basilisk", Bigfoot if entered species name is "Bigfoot"). Input will loop until the word"Done"is entered for the beast's name.
Example of program execution:
Beast Name: Scott
Beast Weight:
40.5
Beast Species(Basilisk/Bigfoot):
Basilisk
Beast Name:
Done
(program execution ends).
Requested files
Bigfoot.java
public class Bigfoot extends MagicBeast {
//TODO: add constructor that takes name, weight and species name arguments
// call the 'parent class' constructor with super(name, weight, species);
//TODO: create an overriddent makeNoise() to return "Rawr"
// this is just like we did with the toSTring() method in lecture
}
MagicBeast.java
public abstract class MagicBeast {
private String name;
private double weight;
private String speciesName;
public MagicBeast(String name, double weight, String speciesName) {
this.name = name;
this.weight = weight;
this.speciesName = speciesName;
}
public String getName() {
return name;
}
public double getWeight() {
return weight;
}
/**
* make a beastly noise.
* TODO: implement this method in Basilisk and Bigfoot subclasses.
*/
public abstract String makeNoise();
}
CryptoManager.java
import java.util.ArrayList;
public class CryptoManager {
private ArrayListMagicBeast> beasts;
public CryptoManager() {
beasts = new ArrayList();
}
public CryptoManager(ArrayListMagicBeast> beasts) {
this.beasts = beasts;
}
/**
* Add a MagicBeast object into the ArrayList of Beasts
* Bigfoot and Basilisk objects count as MagicBeast objects
* @param beast the MagicBeast object being added
*/
public void addBeast(MagicBeast beast) {
//TODO:
}
public void printBeasts() {
for (MagicBeast beast : beasts) {
System.out.println("Name: " + beast.getName());
System.out.println("Weight: " + beast.getWeight());
System.out.println("Call: " + beast.makeNoise());
}
}
}
Basilisk.java
public class Basilisk extends MagicBeast {
//TODO: add constructor that takes name, weight and species name arguments
// call the 'parent class' constructor with super(name, weight, species);'
// TODO: complete an overridden makeNoise() to return "Squawk"
// this is just like we did with the toSTring() method in lecture
}
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