Skip to content

Instantly share code, notes, and snippets.

@nbavafa
Created February 18, 2015 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbavafa/9e9e939055c7f1eeced3 to your computer and use it in GitHub Desktop.
Save nbavafa/9e9e939055c7f1eeced3 to your computer and use it in GitHub Desktop.
Mammal
package mammal;
public class Kangaroo {
private double pouchVolume;
private double highJump;
private double tailLength;
public double getpouchVolume() {
return pouchVolume;
}
public void setpouchVolume(double pouchVolume) {
this.pouchVolume = pouchVolume;
}
public double gethighJump() {
return highJump;
}
public void sethighJump(double highJump) {
this.highJump = highJump;
}
public double gettailLength() {
return tailLength;
}
public void settailLength(double tailLength) {
this.tailLength = tailLength;
}
}
package mammal;
public class Mammal {
private int lifeExpectancy;
private int birthYear;
private double avgNumOffspring;
public int getLifeExpectancy() {
return lifeExpectancy;
}
public void setLifeExpectancy(int lifeExpectancy) {
this.lifeExpectancy = lifeExpectancy;
}
// public void setLifeExpectancy(int myLifeExpectancy) {
//lifeExpectancy = myLifeExpectancy;
///}
public int getBirthYear() {
return birthYear;
}
public void setBirthYear(int birthYear) {
this.birthYear = birthYear;
}
public double getAvgNumOffspring() {
return avgNumOffspring;
}
public void setAvgNumOffspring(double avgNumOffspring) {
this.avgNumOffspring = avgNumOffspring;
}
public int yearsLeft(int birthYear, int currentYear, int lifeExpectancy) {
int age = currentYear-birthYear;
return lifeExpectancy - age;
}
public int currentAge(int birthYear, int currentYear) {
return currentYear - birthYear;
}
public int currentAge() {
return currentYear() - birthYear;
}
public int yearsLeft() {
return lifeExpectancy - currentAge();
}
public int currentYear() {
return 2015;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment