Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Cats;
- public class Cat {
- /* Properties */
- protected String name,
- colour;
- protected float whiskersLength;
- /* Get, Set Methods */
- public void setName(String name) {
- this.name = name;
- }
- public String getName() {
- return this.name;
- }
- public void setColour(String colour) {
- this.colour = colour;
- }
- public String getColour() {
- return this.colour;
- }
- public void setWhiskersLength(float whiskersLength) {
- this.whiskersLength = whiskersLength;
- }
- public String setColour() {
- return this.colour;
- }
- /* Constructors */
- public Cat(String name, float whiskersLength, String colour) {
- this.name = name;
- this.colour = colour;
- this.whiskersLength = whiskersLength;
- }
- public Cat(String name, float whiskersLength) {
- this(name, whiskersLength, "");
- }
- public Cat(String name) {
- this(name, 0, "Ginger");
- }
- public Cat() {
- this("Blacky, the Black Cat", 10, "Black");
- }
- /* Copy Constructor */
- public Cat(Cat catObj) {
- this.name = catObj.name;
- this.colour = catObj.colour;
- this.whiskersLength = catObj.whiskersLength;
- }
- /* Methods */
- public String toString() {
- String output = String.format("(%s@%h)\tname=\"%s\"\tcolour=\"%s\"\twhiskers=%.2fcm",
- this.getClass().getName(), this, name, colour, whiskersLength);
- return output;
- }
- }
Add Comment
Please, Sign In to add comment