DUE: Sun May 15, 11 pm
(10% penalty for late submission, up to 1 day late)
Any changes to this document, typically due to an error on the part of the author, will be logged here.
Collaboration is strongly ENCOURAGED within a programming team, but the program you submit must still represent YOUR OWN original work. Teams should work on the algorithm together, and help debug/test each others code. However, copying code from ANY outside source (any book, current or past students, past solutions, web sites, etc.) is STRICTLY FORBIDDEN. Copy and Paste from another solution, including the solution of a team mate will incur a stiff penalty.
For this assignment you will be writing a "text viewer" using the Big C++ graphics package. The goal is to be able to read a file in the graphics window. You will implement a TextViewer class which displays a file in the graphic window. The interface of the class is described below. You are not allowed to change the public interface. However, you may do whatever you wish for the private interface. The private functions shown here are merely suggestions; you can use them, or make up your own.
In addition to implementing the class, you will write a main ( ccc_win_main ) program which tests your function. The main function will set up the graphic window so the upper left hand corner is at the point ( 0, 0 ) and the lower right hand corner is at the point ( 100, 100 ). It will then attempts to sequentially open three files for viewing. The first file is act 1, scene 1 of Hamlet. The second file is the Declaration of Independence. The third file should not exist; this will test whether the class operates correctly when it can't open a file. These text files are provided in the framework.
The TextViewer will make the assumption that the graphic window is set up so that the upper left hand corner is at the point ( 0, 0 ) and the lower right hand corner is at the point ( 100, 100 ). When the view method of the TextViewer is called; it will display the text of the file in the graphic window starting at the beginning of the original file. It will display up to 30 lines of text at a time for the user to read. Each line will be no more than 48 characters long. A line should not break in the middle of a word unless the word is longer than 48 characters. Also, return characters from the original file should be preserved. The displayed text should take up no more that 80 percent of the vertical area of the graphic window. This will allow for the top 5 percent of the window to be blank, and the bottom 15 percent of the window will be left for buttons. The constants declared in global_const.h are set up to adhere to these restrictions.
Two buttons can be displayed by the TextViewer. The "Done"
button will always be displayed in the bottom of the window. If the user
clicks the "Done" button the TextViewer will stop displaying the
contents of the file. There will also be a "Next" button that
will move to the next page of the text. If all of the text has been
displayed, the "Next" button should be hidden so that the user
is aware that the end of the file has been reached.
In the event that the file the TextViewer is supposed to read from
can not be opened. The TextViewer should display a message stating the
problem and wait for the user to click the "Done" button.
For this assignment a framwork will be provided for you which includes all of the files that are necessary for you to complete the assignment. The files included in the framework are the following:
You may download the framework here. To uncompress the framework archive you should type:
where <framework_file> is the name of the file that you downloaded.
Submit your work electronically to the correct folder on the cs secure server. Don't forget to include the header template at the top of each file that you submit.
For this assignment you will turn in the following files:
You can download a sample program right-clicking and save as here. Place the file assn7_sample in the assn7 folder that came with the framework in order for it to be able to access the text files. You will probably need to change the permissions on assn7_sample so that it is user executable. You can do this with the command:
Only write a small portion of code before checking that it still compiles. This way when you get a syntax error, you can be fairly certain the error is in the part you just wrote.
The points for this assignment will be distributed as follows:
| Points | Feature Description |
|---|---|
| 2 pts | Program compiles( And files represent an attempt at completing the assignment ) |
| 3 pts |
Adherence to the class coding standard -- ( .5 pts ) Program does not use global variables or objects -- ( .5 pts ) Good variable and function names -- ( .5 pts ) Proper indentation and spacing -- ( .5 pts ) Good comments ( including header and function comments ) -- ( .5 pts ) No line wraps -- ( .5 pts ) Other miscellaneous parts of the standard. |
| .5 pts | Lines are 48 characters or less. |
| .5 pts | Lines do not break in the middle of a word. |
| .5 pts | Return characters are preserved. |
| .5 pts | 30 lines per page. |
| .5 pts | Multiple page support. |
| .5 pts | Done button exits the viewer. |
| .5 pts | Next button moves to next page. |
| .5 pts | Next button is not shown on last page. |
| .5 pts | Error message is given for non-openable file. |
| .5 pts | Main program attempts to display the three files given in the framework. |