- #1
Bellatrix6
- 1
- 0
Homework Statement
Suppose that you are given the following PetDriver class, which includes a main method:
public class PetDriver{
public static void main(String[] args){
int weight = 40;
Pet doggie = new Pet("Rover", weight);
System.out.println("my pet's name is " + doggie.getName());
System.out.println("my pet's weight is " + doggie.getWeight());
}
}
Executing main produces the following output:
my pet's name is Rover
my pet's weight is 40
Complete the Pet class definition, below, so that the main method shown above works correctly.
Homework Equations
The Attempt at a Solution
This is what I tried, but it didn't work:
public class Pet{
private String name;
private int weight;
public Pet(String who, int pounds){
name = who;
weight = pounds;
}
public String getName(){return name;}
public int getWeight(){return weight;}
}