Skip to content

Instantly share code, notes, and snippets.

@QuanSai
Created November 14, 2012 03:43
Show Gist options
  • Save QuanSai/4070130 to your computer and use it in GitHub Desktop.
Save QuanSai/4070130 to your computer and use it in GitHub Desktop.
Class demonstration
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