DUE: Sun April 17, 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 assignment2 you had to write a function which drew a "button" in the drawing area. Once again we will continue on a familiar theme, but this time you will be implementing a "button object" by writing a button class.
As we hope to use the button class later, we will try to give it a robust, yet general set of functionalities. A description of the methods which provide these functionalities follows:
Again you will be given the file "global_const.h" which contains constants describing the size of text drawn in the drawing area. You may take the specification of how the button is to be drawn from the Button Specification in assignment2. The declaration of the button class is provided for you. You must write the function definition for the methods of the button class.
You will then 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 draw a button centered in the window with the label of "quit" and another button in the upper right hand corner with a label of "show/hide". If the "show/hide" button is clicked, the shown status of the "quit" button should be toggled. If the "quit" button is clicked, the program should terminate. If any other point in the drawing area is clicked, the "quit" button should be centered on the point where the drawing area was clicked. Any time a click is made in the drawing area, the window should be cleared and all the objects in the drawing area should be redrawn.
In the event that the buttons overlap, and the drawing area is clicked in the region where the two buttons overlap, you should assume that the "show/hide" button is clicked rather than the "quit" 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.
Your code must compile on the school's linux system, using the flags specified in the class coding standards. You must provide a makefile with the targets "all" and "clean" so the grader can compile you assignment. Submit your work (the source file(s) and Makefile ONLY) 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:
The files should be inside a folder named assn3. Each file that you have written should conform to the class coding standard. This includes but is not limited to:
You can soon download a sample program by right-clicking and save-as here. You will probably need to change the permissions on the file so that it is user executable. You can do this with the command:
If your program does not compile, it will not be graded. Compile your code often. 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 |
| 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. |
| 1 pts | Program draws both buttons. |
| 1 pts | Hide/show button works properly. |
| 1 pts | Program exits when the "quit" button is clicked. |
| 2 pts | "Quit" button is centered on a point in the drawing area when the drawing area is clicked. |