CS
010 - Introduction to Computer Science I
Assignment 8:
DUE: March 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 as8 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 connects some
points in the graphics window. The program will continue to ask the
user to click the window, until they double click the same spot. Each
time they click the window, your program should draw a point where the
window was clicked. After the last point is double clicked, your
program will connect all the points in the order that they occured, and
then end.
You don't know how many times the user is going to click the
window, so you should store all your points in a vector. Do not
connect the points until
after
the user has double clicked (the last point). If the user double clicks
before any points are added to the window, your program should just
*connect* the same point. In other words, if there is only two points
total, it is OK to cwin a Line "between" those two Points, even though
they have the same x and y values.
To check if the same point has been clicked twice, you should
create a function called same_point. The function is passed two
points, and returns true if they are the same, or false if they are
different. When same_point returns true, you should stop asking the
user to click the window, and connect the points.
Use a for loop to connect the points stored in the vector.
Hint:
Use the vector size() function to connect the lines the correct number
of times in your for loop.
Example program download
main
Rubric: (10 pts total)
2 pt(s): Function is used to compare two points, and returns true
or false correctly.
1 pt(s): Points are correctly stored in a vector, and printed to window
each time the user single clicks.
1 pt(s): Continues to ask the user to click the window, until they
double click.
2 pt(s): For loop is used to print out the lines.
3 pt(s): Points are not connected until AFTER the user double clicks,
and they are connected correctly.
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