|
|
|
ifstream myFile; // declare an
input file stream |
|
GetInputFile(myFile); // call
function GetInputFile (see slide 4) |
|
int x1, y1, x2, y2; //
declare variables for rectangle |
|
int xcenter, ycenter, r; //
declare variables for circle |
|
string label; // declare
variable for label |
|
while (myFile.peek() != EOF)
{ // test if at the End Of File (EOF) |
|
myFile >> label; //
read label |
|
if (label == "circle") { |
|
myFile >> xcenter >>
ycenter >> r; // read xcenter, ycenter and r |
|
PaintCircle(xcenter,ycenter,r); //
paint a circle |
|
} |
|
else if (label =="rectangle")
{ |
|
myFile >> x1 >> y1
>> x2 >> y2; // read x1, y1, x2, y2 |
|
PaintRect(x1,y1,x2,y2); //
paint a rectangle |
|
} |
|
} |
|
myFile.close(); //
close the file stream |