I was wondering is it possible to put this into an array so that it would print the same thing three times?
ChineseFireball dragon = ChineseFireball("Scarlet", "Beast", "China", 6, 25);
dragon.print();
/* Populate */
ChineseFireball dragons[3];
for (int i = 0; i < 3; i++)
{
dragons[i] = ChineseFireball("Scarlet", "Beast", "China", 6, 25);
}
/* Print */
for (int i = 0; i < 3; i++)
{
dragons[i].print();
}
if array is not necessary:
ChineseFireball dragon = ChineseFireball("Scarlet", "Beast", "China", 6, 25);
for (int i = 0; i < 3; i++)
{
dragon.print();
}
Sure, here is how:
ChineseFireball dragons[3];
for (int i = 0; i < 3; i++)
{
dragons[i] = ChineseFireball("Scarlet", "Beast", "China", 6, 25);
}
And then to print, simply loop through the dragons array and call print() on each element.
That's assuming you want to have three dragons. If you simply want to execute print() on the single dragon instance three times, run it in a loop like the one above.