CS
010 - Introduction to Computer Science I
Assignment 2:
DUE: Friday, October 15th before 5:00pm
Collaboration is strongly ENCOURAGED. You will be working in teams, but programs must represent YOUR OWN original work. Teams should 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 will be similar, but you are not allowed to just copy a teamate's solution.
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 using electronic turnin, from a computer on campus.
Turn in online to as2_(group letter) 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).
Remember to include the following header
information at the top of your program;
// 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)
//
// Group: Enter your group here (eg, D4)
// Teammates: List the names of the teammates you worked with
// Meeting Time: Specify the next time your team plans to meet
//
//
=======================================================================
For this assignment you will write a program that draws a picture.
The picture must have 3 different elements; a space ship, a
landscape, and a big C on the landscape (below is an example).
You can draw the ship and landscape any way you like, so be
creative! To create the images, and print the C, you will need to
include the "ccc_win.h" library in your program. You are required
use the following functions; Point, Line, and Message. The
code sample below draws a line, and prints a message to the window:
#include "ccc_win.h"
using namespace std;
int ccc_win_main()
{
//set window coordinates (pg. 98)
cwin.coord(0, 1000, 1000, 0);
//start and end point of line
Point p0(250, 500);
Point p1(750, 500);
//location of message
Point msg_loc(250, 600);
//draw a line from point p0 to p1
cwin << Line(p0, p1);
//print a message
cwin << Message(msg_loc, "I just drew a line");
return 0;
}
Now that we are using
graphics, you need to make changes to the way you've been compiling
and running your program, you also need to use ccc_win_main(), instead
of main() at the start of your program (as in the sample code above).
To compile the program now, type "compile"
on the command line instead of "g++ main.cpp". To run the program
now type "main" instead of "a.out".
Example program run displaying picture:
1 pt: Draws a ship with at least 4 lines
1 pt: Draws a landscape with at least 7 lines
2 pts: Uses Point and Line functions to draw ship and landscape
2 pts: Prints a C on the landscape with Message function
1 pt: Header info (provide correct info specified above)
1 pt: Compiles without errors
2 pts: Style (0.5 each)
- Good variable names
- Proper indentation
- Good comments
- No line wraps
Bonus +1 point
Use the get_int function (pg. 102) to first ask the user for the
location in the window that the ship should be drawn, and then draw the
ship at that point.
Bonus +1 point
Read ahead and figure out how to use an "if statement" to check
if the x, and y value is inside the window coordinates. If they
are, draw the ship, else don't draw the ship.