K
Kelly Mandrake
I have defined and declared 3 Cat objects which want to display
information on each via a for loop. I have a value n, which
increments, but I am not sure how I would change the call to each Cats
methods so that the value n replaces the 1 for example:
myCatn.GetAge() >> where n gets replaced.
Ive thought about adding a Display() method for cat but then i will
still find myself calling display on each cat in the loop.
Maybe someone can sugest a way to do this easyer.
Code:
Cat myCat1; // RagDoll, 1 year old, weighs 6 lbs
Cat myCat2(Persian, 2); // Persian, 2 years old, weighs 6 lbs
Cat myCat3(RagDoll, 5, 10); // RagDoll, 5 years old, weighs 10 lbs;
for (int n = 1; n < 4; n++)
{
cout << "Cat: myCat" << n << "\n\n";
cout << "Breed: " << myCat1.GetBreed() << endl;
cout << "Age: " << myCat1.GetAge() << endl;
cout << "Weight: " << myCat1.GetWeight() << endl;
}
information on each via a for loop. I have a value n, which
increments, but I am not sure how I would change the call to each Cats
methods so that the value n replaces the 1 for example:
myCatn.GetAge() >> where n gets replaced.
Ive thought about adding a Display() method for cat but then i will
still find myself calling display on each cat in the loop.
Maybe someone can sugest a way to do this easyer.
Code:
Cat myCat1; // RagDoll, 1 year old, weighs 6 lbs
Cat myCat2(Persian, 2); // Persian, 2 years old, weighs 6 lbs
Cat myCat3(RagDoll, 5, 10); // RagDoll, 5 years old, weighs 10 lbs;
for (int n = 1; n < 4; n++)
{
cout << "Cat: myCat" << n << "\n\n";
cout << "Breed: " << myCat1.GetBreed() << endl;
cout << "Age: " << myCat1.GetAge() << endl;
cout << "Weight: " << myCat1.GetWeight() << endl;
}