DUE: Sun April 3, 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.
In lab1 there was a task which addressed the need to be able to draw a particular shape at various different sizes. This is a problem that we will run into when we implement the card class that we will use for our game suite. Depending on the size of the card that we draw for a particular game, the suits that appear on the card will have to be drawn at different sizes. Drawing each of the symbols for the 4 suits in a deck of cards can be quite time consuming, so rather than drawing all four suits, we're only going to ask you to draw 1 of them.
For this assignment you will write a function which takes as parameters the center of the diamond and the height of the diamond and then draws a diamond shape in the graphic window. The declaration of the function is as follows:
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 diamond centered in the graphic window and 20 units high.
It will then prompt the user ( take a look at the cwin.get_double( s ) function ) for the next height to draw the diamond at, clear the window and redraw the diamond at the specified height. The height of the diamond is measured from the top point to the bottom point of the diamond. The program will continue prompting the user for a new height and redrawing the diamond until the user enters "0" as the height, at which point the program will terminate. The window does not need to "disappear" after the user chooses a size of 0 for the diamond, but the program should halt. You can download an example in the Example section to observe the desired behavior.
For this assignment a framwork will be provided for you which includes a makefile that you must use to compile the project. To compile the program simply type "make" on the command line in the directory containing your files. You may download the framework here. To unzip the framework archive you should type:
just as you did in lab1 to unzip the lab1 framework. If for some reason your browser downloads the framework as "assn1_framework.tgz.tar" you can still unzip it with the command:
Your code must compile on the school's linux system, using the flags specified in the class coding standards. ( For this assignment a Makefile will be provided which complies with the class coding standard. ) Submit your work (the source file(s) and Makefile ONLY) electronically to the assn1 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 a file main.cpp which contains the test program and the function which draws a diamond, and the Makefile which is provided with the framework. ( To compile the program with them makefile, simply type "make". To run the program type "./a.out" ) The files should be inside a folder named assn1. Each file that you have written ( main.cpp ) should conform to the class coding standards. This includes but is not limited to:
You may 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. |
| 2 pts | Program draws a diamond |
| 2 pts | Program resizes the diamond correctly |
| 1 pts | Program prompts the user for input correctly and exits on an input of 0 |