Commit 84365613 authored by harry.sawdon's avatar harry.sawdon

second commit

parent 8fec08e3
package inheritanceTest; package inheritanceTest;
public class Animal { public class Animal {// defines custom class animal to set up inheritance system.
// definition of argument names and data types
protected String name; protected String name;
protected String enviro; protected String enviro;
protected String eats; protected String eats;
...@@ -13,7 +13,7 @@ public class Animal { ...@@ -13,7 +13,7 @@ public class Animal {
public Animal(){} public Animal(){}
public Animal(String Name, String habitat, String food, String legs, String wingspan, String length, String description){ public Animal(String Name, String habitat, String food, String legs, String wingspan, String length, String description){//assigns arguments to animal class and all extensions
this.name = Name; this.name = Name;
this.enviro = habitat; this.enviro = habitat;
this.eats = food; this.eats = food;
...@@ -22,7 +22,7 @@ public class Animal { ...@@ -22,7 +22,7 @@ public class Animal {
this.Length= length; this.Length= length;
this.Description = description; this.Description = description;
} }
// sets return parameters for each argument
public String getName() { public String getName() {
return name; return name;
} }
......
package inheritanceTest; package inheritanceTest;
public class Bird extends Animal{ public class Bird extends Animal{//defines bird class as extension of animal
public Bird(String Name, String habitat, String food, String legs, String wingspan, String length, String Description) { public Bird(String Name, String habitat, String food, String legs, String wingspan, String length, String Description) {
super(Name, habitat, food, legs, wingspan, length, Description); super(Name, habitat, food, legs, wingspan, length, Description);// provides arguments for bird type animal
} }
...@@ -12,7 +12,7 @@ public class Bird extends Animal{ ...@@ -12,7 +12,7 @@ public class Bird extends Animal{
@Override @Override
public String toString() { public String toString() {//forces all args to return a string data type(not really needed but a safety measure)
return name + enviro + eats + noOfLegs + wings + Length + Description; return name + enviro + eats + noOfLegs + wings + Length + Description;
} }
} }
...@@ -2,17 +2,17 @@ package inheritanceTest; ...@@ -2,17 +2,17 @@ package inheritanceTest;
public class Fish extends Animal{ public class Fish extends Animal{//defines fish class as extension of animal
public Fish(String Name, String habitat, String food, String legs, String wingspan, String length, String Description) { public Fish(String Name, String habitat, String food, String legs, String wingspan, String length, String Description) {
super(Name, habitat, food, legs, wingspan, length, Description); super(Name, habitat, food, legs, wingspan, length, Description);// provides arguments for fish type animal
} }
@Override @Override
public String toString() { public String toString() {//forces all args to return a string data type(not really needed but a safety measure)
return name + enviro + eats + noOfLegs + wings + Length + Description; return name + enviro + eats + noOfLegs + wings + Length + Description;
} }
} }
......
package inheritanceTest; package inheritanceTest;
public class Mammal extends Animal{ public class Mammal extends Animal{//defines mammal class as extension of animal
public Mammal(String Name, String habitat, String food, String legs, String wings, String length, String Description) { public Mammal(String Name, String habitat, String food, String legs, String wings, String length, String Description) {
super(Name, habitat, food, legs, wings, length, Description); super(Name, habitat, food, legs, wings, length, Description);// provides arguments for mammal type animal
} }
@Override @Override
public String toString() { public String toString() {//forces all args to return a string data type(not really needed but a safety measure)
return name + enviro + eats + noOfLegs + wings + Length + Description; return name + enviro + eats + noOfLegs + wings + Length + Description;
} }
......
package inheritanceTest; package inheritanceTest;
public class Reptile extends Animal{ public class Reptile extends Animal{//defines reptile class as extension of animal
public Reptile(String Name, String habitat, String food, String legs, String wingspan, String length, String Description) { public Reptile(String Name, String habitat, String food, String legs, String wingspan, String length, String Description) {
super(Name, habitat, food, legs, wingspan, length, Description); super(Name, habitat, food, legs, wingspan, length, Description);// provides arguments for reptile type animal
} }
@Override @Override
public String toString() { public String toString() {//forces all args to return a string data type(not really needed but a safety measure)
return name + enviro + eats + noOfLegs + wings + Length + Description; return name + enviro + eats + noOfLegs + wings + Length + Description;
} }
......
This diff is collapsed.
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