Created
April 6, 2016 05:04
-
-
Save enl/dd77a03bbda2742291ddbde78887d8b2 to your computer and use it in GitHub Desktop.
Cats constructor overload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Color {} | |
class Address {} | |
class Cat { | |
private Int age; | |
private Double weight; | |
private String name; | |
private Address address; | |
private Color color; | |
Cat(String name) { | |
super(name, Cat.getDefaultWeight(), Cat.getDefaultAge()) | |
} | |
Cat(String name, Double weight, Int age) { | |
this.name = name; | |
this.weight = weight; | |
this.age = age; | |
} | |
Cat(String name, Int age) { | |
super(name, Cat.getDefaultWeight(), age); | |
} | |
Cat(Color color, Double weight) { | |
super(null, weight, Cat.getDefaultAge()); | |
this.color = color; | |
} | |
Cat(Color color, Double weight, Address address) { | |
super(color, weight); | |
this.address = address; | |
} | |
static Double getDefaultWeight() { | |
return 3.5; | |
} | |
static Int getDefaultAge() { | |
return 2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment