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{ ...@@ -7,8 +7,8 @@ public class Baboon extends Mammal{
hierarchy = 0; 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){ 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, fc, loco); super(hb, fd, nm, a, integ, gnd, nol, spd, hgt, loco);
hierarchy = hrchy; hierarchy = hrchy;
} }
...@@ -16,4 +16,5 @@ public class Baboon extends Mammal{ ...@@ -16,4 +16,5 @@ public class Baboon extends Mammal{
public void shout(){ public void shout(){
System.out.println("OOAAAAOOOAAAAHAAAWWOOOHAAA"); System.out.println("OOAAAAOOOAAAAHAAAWWOOOHAAA");
} }
} }
import java.text.DecimalFormat;
abstract class Bird extends Animal{ abstract class Bird extends Animal{
protected double wingSpan; protected double wingSpan;
protected double migration;
protected String featherColour; protected String featherColour;
protected static final DecimalFormat df = new DecimalFormat("0.00");
public Bird(){ public Bird(){
super(); super();
this.wingSpan = 5.5; this.wingSpan = 5.5;
this.migration = 120;
this.featherColour = "Green"; 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); super(hb, fd, nm, a, integ, gnd, nol, spd);
this.wingSpan = ws; this.wingSpan = ws;
this.migration = mig;
this.featherColour = fc; this.featherColour = fc;
} }
public void flight(){ public void flight(){
System.out.println(this.name + " flew " + df.format(this.speed) + "m!");
} }
} }
...@@ -2,8 +2,8 @@ public class Catfish extends Fish{ ...@@ -2,8 +2,8 @@ public class Catfish extends Fish{
protected double whiskerLength; 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){ 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, md, len); super(hb, fd, nm, a, integ, gnd, nol, spd, culs, len);
whiskerLength = wl; whiskerLength = wl;
} }
......
public class Duck extends Bird{ public class Duck extends Bird{
public Duck(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double ws, double mig, String fc){ protected Boolean bread = true;
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(){ public void swim(){
System.out.println(this.name + "swims around the pond happily"); System.out.println(this.name + "swims around the pond happily");
} }
} }
...@@ -6,9 +6,13 @@ public class Emu extends Bird{ ...@@ -6,9 +6,13 @@ public class Emu extends Bird{
this.runningSpeed = 20; 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){ 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, mig, fc); super(hb, fd, nm, a, integ, gnd, nol, spd, ws, fc);
this.runningSpeed = spd*3; this.runningSpeed = spd*3;
} }
@Override
public void flight(){
System.out.println("Emu's can't fly!");
}
} }
abstract public class Fish extends Animal{ abstract public class Fish extends Animal{
protected String Colourings; protected String Colourings;
protected int migrationDistance;
protected int length; 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); super(hb, fd, nm, a, integ, gnd, nol, spd);
Colourings = culs; Colourings = culs;
migrationDistance = md;
length = len; length = len;
} }
} }
...@@ -7,8 +7,8 @@ public class Lion extends Mammal{ ...@@ -7,8 +7,8 @@ public class Lion extends Mammal{
timeSpentAsleep = 24; 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){ 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, fc, loco); super(hb, fd, nm, a, integ, gnd, nol, spd, hgt, loco);
timeSpentAsleep = tsa; timeSpentAsleep = tsa;
} }
} }
abstract public class Mammal extends Animal{ abstract public class Mammal extends Animal{
protected double height; protected double height;
protected String furColour;
protected String locomotion; //Do they vibe on two legs or four? protected String locomotion; //Do they vibe on two legs or four?
public Mammal(){ public Mammal(){
super(); super();
height = 2.0f; height = 2.0f;
furColour = "nil";
locomotion = "wheels"; 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); super(hb, fd, nm, a, integ, gnd, nol, spd);
height = hgt; height = hgt;
furColour = fc;
locomotion = loco; locomotion = loco;
} }
......
public class Parrot extends Bird{ public class Parrot extends Bird{
protected int volumeDecibels;
public Parrot(){ public Parrot(){
super(); 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){ 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, mig, fc); super(hb, fd, nm, a, integ, gnd, nol, spd, ws, fc);
volumeDecibels = vdb;
} }
public void mimicry(String input){ public void mimicry(String input){
......
public class PufferFish extends Fish{ public class PufferFish extends Fish{
protected boolean isExpanded = false; 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){ 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, md, len); super(hb, fd, nm, a, integ, gnd, nol, spd, culs, len);
radiusExpanded = re;
} }
public void expansion(){ public void expansion(){
......
...@@ -10,8 +10,8 @@ public class RedPanda extends Mammal{ ...@@ -10,8 +10,8 @@ public class RedPanda extends Mammal{
homeRange = 2.1; 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){ 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, fc, loco); super(hb, fd, nm, a, integ, gnd, nol, spd, hgt, loco);
homeRange = hora; homeRange = hora;
} }
......
...@@ -2,8 +2,8 @@ public class Shark extends Fish{ ...@@ -2,8 +2,8 @@ public class Shark extends Fish{
protected int teeth; 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){ 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, md, len); super(hb, fd, nm, a, integ, gnd, nol, spd, culs, len);
teeth = tth; 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