How can I make this function work for 100 objects(c++)?

A

aj_23

Guest
So I have a program that shows the numbers in a text file of each object, the problem is that the original program is with only 6 objects, which I found preety easy, but now I have to change it to work with 100 objects. I tried using a for loop but it only showed me the first object. I don't have much experience programming and have tried other ways but none of them work. Anyways, here's the function:

void Circle::writeAll(Circle circle[6], int &count) {
if (count == 0) {
cout << "No circles in file. " << endl << endl;
};
if (count == 1 || count == 2 || count == 3 || count == 4 || count == 5 || count == 6) {
cout << " Radius: " << circle[0].getRadius() << "; Center(x): " << circle[0].getCenterx() << "; Center(y): " << circle[0].getCentery() << endl;
};
if (count == 2 || count == 3 || count == 4 || count == 5 || count == 6) {
cout << " Radius: " << circle[1].getRadius() << "; Center(x): " << circle[1].getCenterx() << "; Center(y): " << circle[1].getCentery() << endl;
};
if (count == 3 || count == 4 || count == 5 || count == 6) {
cout << " Radius: " << circle[2].getRadius() << "; Center(x): " << circle[2].getCenterx() << "; Centery(y): " << circle[2].getCentery() << endl;
};
if (count == 4 || count == 5 || count == 6){
cout << " Radio: " << circle[3].getRadius() << "; Center(x): " << circle[3].getCenterx() << "; Center(y): " << circle[3].getCentery() << endl;
};
if (count == 5 || count == 6){
cout << " Radius: " << circle[4].getRadius() << "; Center(x): " << circle[4].getCenterx() << "; Center(y): " << circle[4].getCentery() << endl;
};
if (count == 6){
cout << " Radio: " << circle[5].getRadius() << "; Center(x): " << circle[5].getCenterx() << "; Center(y): " << circle[5].getCentery() << endl;
};
cout << endl;


};

Continue reading...
 
Top