CS 010 - Introduction to Computer Science I
Assignment 4:

DUE: February 11th before 7:00pm


Collaboration Policy

Collaboration is strongly ENCOURAGED. You can work in teams, but programs must represent YOUR OWN original work. Teams can work on the algorithm together and help debug/test each others code. However, copying code from ANY source (any book, current or past students, past solutions, the web, etc.) is STRICTLY FORBIDDEN. Code between teamates might be similar, but you are not allowed to just copy and paste a teamate's solution.  Also, just changing the variable names and spacing from someone elses code is considered cheating, and will result in at least a zero for the assignment.


Code that is turned in, must be contained in a .cpp file named main.cpp. Files of any other format will not be graded (e.g. main.doc, main.txt, etc…).

You must turn your work in from a lab computer on campus.

Turn in online to as4 folder. If you turn your assignment in to the wrong folder, your assignment may not be graded. If it is graded, you will lose 2 pts (out of 10).

If your program does not compile, you will receive a zero for this assignment!

Remember to include the following header information at the top of your program, failure to do so will result in lose of points.

// Course: CS 10
//
// Lecture Section: ... 001 or 002
// Lab Section: ... 021, 022, etc)
//
// Assignment #: ... assignment 2, 3, etc.
//
// Last Name: Enter your LAST (family) name here (eg, Doe)
// First Name: Enter your FIRST (given) name here (eg, John)
//
// ID Number: Enter your ID number here (eg, 860-00-0000)
// lab login id: Enter your cs10 login here (eg, jdoe)
//
// Email address: Enter your UCR email address here (eg, jdoe@cs.ucr.edu)
//
// Teammates: List the names of the teammates you worked with

// =======================================================================



Problem Definition:

    For this assignment you will write a program that allows you to move a Circle around in the graphics window, until it touches one of the window's edges.
    The Cirlce will initially be drawn in the center of the window.  The program will then prompt the user for a direction to move the Circle; up, down, left, or right.  The program will then clear and redraw the window with the Circle relocated as specified by the user.  The program should continue in this way, until the Circle passes through one of the window's edges.  If the Circle passes through the window's edge, the program will print the message "klunk!" to the middle of the screen.
    No matter where the Circle makes contact (top, bottom, left, or right side of the window) the Circle has to be EXACTLY half visible at the place it passed through the edge (this includes the corners of the window).  Because of this, you will have to pay careful attention to the dimensions of your window (set using cwin.coord()), the radius of your circle, and to the distance it is moved each time the user selects a movement.
    Once the Message "klunk!" is printed, your program will just wait for the graphics window to be closed.
    IMPORTANT! It should take at least three, but no more than 10 moves to go from the far left, to the far right side of the window, this is also true for moving from the far bottom to the far top of the window.

Hints:  
1)  Before you start writing code, take some time to decide what coordinates to use, how much to move your circle on each move, and the radius of your circle.  Figuring out these things on paper first will save you at least an hour of debugging your program!
2)  Keep track of the point that represents the center of the circle to detect if it has passed through a window's edge.
3)  This program is much more challanging than the last three!  Don't wait till the last minute to start this.

Example program download
main

The above link is attached to an executable version of the program.  Below are instructions to downlaod the program.  Note that this will only work on the lab computers, or computers running linux, so it probably won't work if you try to download it from home on a Windows machine.

1)  Right click the blue link above, and then select "Save Link Target As..." by left clicking.

2)  A message box will open asking you where you want to save the file.  Choose from the list of folders by double clicking on the folder that you want to save the game in.  If you want to save it in your home directory, you can just left click "save".

3)  Now cd into the directory that you saved the game.  On the command line type the following command:
chmod u+x main

You will only need to do this once (the first time).  You can close the other message box that opens (the one that says Download Manager).

4)  From now on, to run the program, you can just type "main" from the command line.


Rubric: (10 pts total)

3 pt(s): Circle is allowed to move while it hasn't passed through an edge.
2 pt(s): Circle moves according to direction given by user.
1 pt(s): Program prints "klunk!" when the Circle passes through the edge.
1 pt(s): Circle is exactly half visiable at point where it passed through edge.
1 pt(s): Screen is cleared and redrawn each time circle is moved.
1 pt(s): Takes at least three, but no more than ten moves to move circle across window.
1 pt(s): Style
- comments
- line wraps
- header info included at top
- spacing
- Indentation
- Good constant/variable names
- No magic numbers

Note that you will lose points for style on this assignment!
For coding style requirements see the following link:
http://www.cs.ucr.edu/cs10/cs10_05win/requirements/coding_std.html