EECS 110: INTRODUCTION TO PROGRAMMING

Programming Assignment #2

If you pair-program, put both names in comments at the start of all your code files. Pair programming means all work done together!

This assignment has two problems. One is a console-based C program, similar to what you did in the first assignment. The second, and more interesting in my opinion, is your first program with graphical output. This program will be the seed of a quarter-long project of your design.

Problem #1: Birth Day Calculator

Do Project 60 in Chapter 5 of the textbook. Call the main C file main.c and put it in a folder called PA2.

Problem #2: Your Interactive Graphics Project, part 1

Write a program that draws a simple but non-trivial picture. Call the main C file main.c and put it in a folder called GAME.

What's in the picture is up to you, but it should be something more interesting and complex than just a couple of rectangles or circles. A stack of 3 circles may be a snowman, but it's no challenge.

As the quarter progresses, you're going to make this picture more complex and interactive, like a simple game or a greeting card. So think about what you'd like build along those lines and draw a picture that fits your intended theme.

To compile and run programs with graphics, you need to include not only the code you write, but extra library code. Library code is code other expert programmers have written to do most of the grungy work for you. Your code plus theirs have to be combined together to make a complete working program.

If you use Microsoft's Visual Studio, use these instructions for creating graphics programs.

If you use Bloodshed's Dev-C++, use these instructions for creating graphics programs.

If you are using XCode on a Macintosh, click on this link to download apple-graphlib.zip from the website. It contains the graphics library and instructions on how to set up the library for use with XCode.

How to Tackle The Graphics Problem

Here's my #1 most important rule for programming: take tiny steps.

And #2: think before you code.

Try to start with a working program -- even a trivial program that does nothing. Then add one simple thing, compile and run, debug if necessary. Then add one more simple thing. Compile and run and debug. Never put in more than one new thing without making sure everything still works. If you have to reorganize things, re-organize a little, but don't add anything new. Compile and run. If you do this faithfully, you'll save hours in debugging time.

In the case of your first graphical project, here's my recommended plan of attack.

Think: Plan the drawing

By doing this in advance, you'll have a method for drawing your shape that can go anywhere on the screen at any size you want. All you'll need to change are three numbers: x, y and width.

Code: Tiny steps


Valid HTML 4.01 Strict