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