CS110 Introduction to Computer Science

Spring 2000

Programming Project #4

Due in class on Tuesday, March 28, 2000.

This project is designed to give you sufficient exposure to the graphics library and the use of simple C++ functions. You will have to demonstrate these programs, live, to me in my office. Scheduling information wil be posted in lectures. Write three seperate C++ programs/projects to accomplish the following:

  1. Program 1: Write a C++ program that inputs the current time (hour and minutes) from the user, and displays a clock face that shows the time. I.e., you have to draw an analog clock whose hour and minute hands correspond to the time entered. Your clock face should ONLY show the 12, 3, 6, and 9 hours marked. For example, for the time 10:08, the following clock will be drawn.

    Note: This program will require your knowledge of basic trigonometric functions.
  2. Program 2: Write C++ functions named Standing(), and Jumping(), that draw a standing and jumping stick figure, respectively, in the Drawing Window. Use these functions in a C++ program that animates the standing and jumping sequences.

         


  3. Program 3: Design a simple animation of your own, and implement it in a C++ program.

Create a separate project for each exercise.

Using the Delay function

For the animations, you may use the following Delay function:

#include <time.h>

void Delay(float);	// prototype

void Delay(float seconds) {	// creates a delay of specified seconds
								// example: Delay(0.2); // o.2 seconds
	// translate seconds into clock ticks
	clock_t ticks = seconds * CLOCKS_PER_SEC;	

	// Get the current tick value of the clock
	clock_t start = clock();

	// Wait until current tick of clock exceeds the delay time
	while (clock() - start < ticks)
		;
}// end of Delay

What to Hand in:

For each Exercise, you will hand in the following:

  1. A printout of your C++ program file.
  2. A printout of your project window (select the project window and choose Print from File menu to get this).
  3. Sample runs only for Program 1.
  4. For the animations, make an appointment with Deepak to show him your animation.

Additionally, write a short paragraph/essay on your experiences in working on this assignment.


Each C++ program should have the following:

// Program Name: <The name of your C++ program file>
// Programmer: <Your name here>
// Address: <your e-mail and Campus Address here>
// Assignment Number: <put project number here, e.g. Project#1, Part A>
// Purpose: <A short problem description>


Back to CS110 Page