166k views
2 votes
Define a member method print_all() for class PetData. Make use of the base class' print_all() method. Sample output for the given program with inputs: 'Fluffy' 5 4444 Name: Fluffy Age: 5 ID: 4444

1 Answer

7 votes

Answer and Explanation:

Using Javascript:

Class PetData{

Constructor(name, age, id){

this.name= name;

this.age =age;

this.id = id;

}

print_all(){

return this.name+""+this.age+""+this.id;

}

}

Here we have defined class PetData with its constructor which would initialize the object/instance of the class when called, example:

Var catData = new PetData(sisi, 1, 2333);

User Ralf Wickum
by
3.1k points