Created
November 14, 2012 03:43
-
-
Save QuanSai/4070130 to your computer and use it in GitHub Desktop.
Class demonstration
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
public class Pet | |
{ | |
private String name; | |
private int age; | |
private double weight; | |
public void writeOutput() | |
{ | |
System.out.println("This is a pet named " + this.name + | |
"who is " + this.age + | |
"years old and weighs " + this.weight); | |
} | |
public void setPet(String newName, int newAge, double newWeight) | |
{ | |
this.age = newAge; | |
this.name = newName; | |
this.weight = newWeight; | |
} | |
public void setName(String newName) | |
{ | |
this.name = newName; | |
} | |
public void setAge(int newAge) | |
{ | |
this.age = newAge; | |
} | |
public void setWeight(double newWeight) | |
{ | |
this.weight = newWeight; | |
} | |
public String getName() | |
{ | |
return this.name; | |
} | |
public int getAge() | |
{ | |
return this.age; | |
} | |
public double getWeight() | |
{ | |
return this.weight; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment