Trying to convert Java to C++ ,I dont know how to do so ,here is the question
Design a class named pet, which should have the following fields:
* name. The name field holds the name of a pet.
* animal. The animal field holds the type of animal that a pet is. Example values are "Dog","Cat",and "Brid".
* age. The age field holds the pet's age.
The pet class should also have the following methods:
* setName. The setName method stores a value in the field.
* setAnimal. The setAnimal method stores a value in the animal field.
* setAge. The setAge method stores value in the age field.
* getName. The getName method returns the value of the name field.
* getAnimal. The getAnimal method returns the value of the animal field.
* getAge. The getAge method returns the value of the age field.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
public class Pet {
private String name;
private String animal;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAnimal() {
return animal;
}
public void setAnimal(String animal) {
this.animal = animal;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
|