Course Home | Assignments | Class Photo | Computing Resources | Lab Hours/Tutoring | Schedule | Submit

Saint Louis University

Computer Science 150
Introduction to Object-Oriented Programming

Michael Goldwasser

Spring 2010

Dept. of Math & Computer Science

Programming Assignment 03

Checkers

Due: 11:59pm, Wednesday, 10 February 2010


Contents:


Collaboration Policy

For this assignment, you must work individually in regard to the design and implementation of your project.

Please make sure you adhere to the policies on academic integrity in this regard.


Overview

The goal of this assignment is to create an image of an initial checkerboard configuration, patterned carefully after the following model (click on image to zoom):

Required Interface

Your program must start out by asking the user for the desired width of the canvas window (which should be square). The rest of your code must be written with enough generality that it creates an appropriate result for the given window size.

Required appearance

Your end result should look precisely like our model image. In particular:

Required techniques

Equally important in this assignment is your technique. You must make legitimate use of control structures to exploit the obvious patterns which exist in the board. Given that the end result is fixed, it would be possible for someone to write code which technically works by individually drawing each of the 64 squares and each of the 24 circles. But you will not receive full credit for such an approach.

As a general rule, if you ever find yourself "copying-and-pasting" code from one part of a program to another, there should be a more elegant way to express the repetition and variation.

Hints techniques

We recommend computing a 'unitSize' variable and basing all of your other geometric computations on that value. This should allow your program to work seemlessly for any canvas size.

Given the large number of objects being added to a Canvas, you may notice that the graphics software cannot do this instantaneously. In some sense, this may be helpful when developing your code, as it almost makes an animation of the board being created piece-by-piece. But if you wish to have a quicker result, please change the "auto refresh" mode of the Canvas. This is done with a command such as paper.setAutoRefresh(False), which can be followed by your code to add all the objects to the board, and then finally a paper.refresh() to render the resulting image.


Submitting Your Assignment

You should create a new file, checkers.py, which contains all of your own code. This file must be submitted electronically.

You should also submit a separate 'readme' text file, as outlined in the general webpage on programming assignments.

Please see details regarding the submission process from the general programming web page, as well as a discussion of the late policy.


Grading Standards

The assignment is worth 10 points.


Extra Credit

If your program is well-designed, you should be able to use it, not only to create the standard 8x8 checkerboard, but to create an NxN checkerboard pattern for any (even) value of N. Let's presume that we wish to define the rules for an NxN game so that each player starts with three rows of checkers (namely the top three rows and the bottom three rows, respectively). For example, here is an image of a hypothetical 20x20 game of checkers.

To meet this goal, ask the user for the canvas size and then for the value of N.


Michael Goldwasser
Last modified: Tuesday, 02 February 2010