Add a new C++ Source called FileRead.cpp to your project. Initialize it with a program outline written by the CSCI 107 instructors.
In this lab you will write a program that reads a description of a drawing from a file and displays it in a window. Each line of the file will describe a shape using six components:
5.0 6.0 3.0 2.0 r r 7.8 3.0 4.0 3.0 r r please ignore the comment 10.0 10.0 2.0 2.0 b e
Colors and shapes are described by one letter. The encoding for colors is given in the comment to the C++ function letter2color. The three shapes are encoded by the letters r, e, and t.
There are three places where you need to modify your program. First, insert your name into the comment on the first line.
Second, look for the comment line that read
// Fill in here to read the lineThis is where you add four more ">> variable" into the while loop condition to read in the other items of the line.
Third, do the hard part. Look for the line
// Fill in here to draw the shapeThis is where you add the code that creates an appropriate shape and draws it to the screen. The minimal requirement for this part of the assignment is that you draw a rectangle of the appropriate dimensions and color. If you are unsure about how to use the function letter2color to transform the input letter into an EzWindows color, you should ask your lab instructor for help.
If you are able to complete the minimal requirement with little trouble, modify your program to vary the types of shapes that it draws.
ifstream fin("C:\\Files\\Lab06.txt") ;Consequently, you will need to have a drawing description stored in C:\Files\Lab06.txt on your computer.
We have provided a sample file for cut-and-paste to help you out here. This file is a "translation" of the C++ face program written by Michael Maher.