Commit 9b6e04b4 authored by jinny.wilkin's avatar jinny.wilkin

final variables + animal creator

parent 2495f873
......@@ -7,8 +7,8 @@ public class Baboon extends Mammal{
hierarchy = 0;
}
public Baboon(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double hgt, String fc, String loco, int hrchy){
super(hb, fd, nm, a, integ, gnd, nol, spd, hgt, fc, loco);
public Baboon(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double hgt, String loco, int hrchy){
super(hb, fd, nm, a, integ, gnd, nol, spd, hgt, loco);
hierarchy = hrchy;
}
......@@ -16,4 +16,5 @@ public class Baboon extends Mammal{
public void shout(){
System.out.println("OOAAAAOOOAAAAHAAAWWOOOHAAA");
}
}
import java.text.DecimalFormat;
abstract class Bird extends Animal{
protected double wingSpan;
protected double migration;
protected String featherColour;
protected static final DecimalFormat df = new DecimalFormat("0.00");
public Bird(){
super();
this.wingSpan = 5.5;
this.migration = 120;
this.featherColour = "Green";
}
public Bird(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double ws, double mig, String fc){
public Bird(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double ws, String fc){
super(hb, fd, nm, a, integ, gnd, nol, spd);
this.wingSpan = ws;
this.migration = mig;
this.featherColour = fc;
}
public void flight(){
System.out.println(this.name + " flew " + df.format(this.speed) + "m!");
}
}
......@@ -2,8 +2,8 @@ public class Catfish extends Fish{
protected double whiskerLength;
public Catfish(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, String culs, int md, int len, double wl){
super(hb, fd, nm, a, integ, gnd, nol, spd, culs, md, len);
public Catfish(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, String culs, int len, double wl){
super(hb, fd, nm, a, integ, gnd, nol, spd, culs, len);
whiskerLength = wl;
}
......
public class Duck extends Bird{
protected Boolean bread = true;
public Duck(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double ws, double mig, String fc){
super(hb, fd, nm, a, integ, gnd, nol, spd, ws, mig, fc);
public Duck(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double ws, String fc, boolean brd){
super(hb, fd, nm, a, integ, gnd, nol, spd, ws, fc);
bread = brd;
if(!bread){
bread = true;
}
}
public void swim(){
System.out.println(this.name + "swims around the pond happily");
}
}
......@@ -6,9 +6,13 @@ public class Emu extends Bird{
this.runningSpeed = 20;
}
public Emu(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double ws, double mig, String fc){
super(hb, fd, nm, a, integ, gnd, nol, spd, ws, mig, fc);
public Emu(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double ws, String fc){
super(hb, fd, nm, a, integ, gnd, nol, spd, ws, fc);
this.runningSpeed = spd*3;
}
@Override
public void flight(){
System.out.println("Emu's can't fly!");
}
}
abstract public class Fish extends Animal{
protected String Colourings;
protected int migrationDistance;
protected int length;
public Fish(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, String culs, int md, int len){
public Fish(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, String culs, int len){
super(hb, fd, nm, a, integ, gnd, nol, spd);
Colourings = culs;
migrationDistance = md;
length = len;
}
}
......@@ -7,8 +7,8 @@ public class Lion extends Mammal{
timeSpentAsleep = 24;
}
public Lion(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double hgt, String fc, String loco, int tsa){
super(hb, fd, nm, a, integ, gnd, nol, spd, hgt, fc, loco);
public Lion(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double hgt, String loco, int tsa){
super(hb, fd, nm, a, integ, gnd, nol, spd, hgt, loco);
timeSpentAsleep = tsa;
}
}
abstract public class Mammal extends Animal{
protected double height;
protected String furColour;
protected String locomotion; //Do they vibe on two legs or four?
public Mammal(){
super();
height = 2.0f;
furColour = "nil";
locomotion = "wheels";
}
public Mammal(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double hgt, String fc, String loco){
public Mammal(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double hgt, String loco){
super(hb, fd, nm, a, integ, gnd, nol, spd);
height = hgt;
furColour = fc;
locomotion = loco;
}
......
public class Parrot extends Bird{
protected int volumeDecibels;
public Parrot(){
super();
volumeDecibels = 155;
}
public Parrot(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double ws, double mig, String fc){
super(hb, fd, nm, a, integ, gnd, nol, spd, ws, mig, fc);
public Parrot(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double ws, String fc, int vdb){
super(hb, fd, nm, a, integ, gnd, nol, spd, ws, fc);
volumeDecibels = vdb;
}
public void mimicry(String input){
......
public class PufferFish extends Fish{
protected boolean isExpanded = false;
protected double radiusExpanded;
public PufferFish(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, String culs, int md, int len){
super(hb, fd, nm, a, integ, gnd, nol, spd, culs, md, len);
public PufferFish(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, String culs, int len, double re){
super(hb, fd, nm, a, integ, gnd, nol, spd, culs, len);
radiusExpanded = re;
}
public void expansion(){
......
......@@ -10,8 +10,8 @@ public class RedPanda extends Mammal{
homeRange = 2.1;
}
public RedPanda(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double hgt, String fc, String loco, double hora){
super(hb, fd, nm, a, integ, gnd, nol, spd, hgt, fc, loco);
public RedPanda(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double hgt, String loco, double hora){
super(hb, fd, nm, a, integ, gnd, nol, spd, hgt, loco);
homeRange = hora;
}
......
......@@ -2,8 +2,8 @@ public class Shark extends Fish{
protected int teeth;
public Shark(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, String culs, int md, int len, int tth){
super(hb, fd, nm, a, integ, gnd, nol, spd, culs, md, len);
public Shark(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, String culs, int len, int tth){
super(hb, fd, nm, a, integ, gnd, nol, spd, culs, len);
teeth = tth;
}
......
import java.util.Scanner;
public class Zoo {
public Animal[] animals;
public Object[] arr = new Object[11];
public void main(){
}
public void createAnimal(){
Scanner input = new Scanner(System.in);
System.out.print("What is the new animal: ");
String newAnimal = input.nextLine();
if (newAnimal.toLowerCase() == "baboon"){
createBaboon();
}
input.close();
}
public void createAnimalClass(){
Scanner in = new Scanner(System.in);
System.out.print("What kind of habitat do they need: ");
arr[0] = in.nextLine();
System.out.print("What food do they eat: ");
arr[1] = in.nextLine();
System.out.print("What is their name: ");
arr[2] = in.nextLine();
System.out.print("How old are they: ");
arr[3] = in.nextLine();
System.out.print("What kind of integument do they possess: ");
arr[4] = in.nextLine();
System.out.print("What is their gender: ");
arr[5] = in.nextLine();
System.out.print("How many legs do they have: ");
arr[6] = in.nextLine();
System.out.print("How fast are they: ");
arr[7] = in.nextLine();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment