CS 201 - Lab 6

In this lab you will modify an existing GUI program (a game) to add a new feature and remove an arbitrary limitation.  One of the best ways to learn about programming is to read and modify existing programs.

The program that you will modify is a game in which the user places disks of various sizes into a rectangular bin.  The game continues until the user places a disk so that it either touches one of the edges of the bin, or overlaps an existing disk.

Getting Started

Import lab6.zip.  (File->Import...->General->Existing Projects into Workspace->Archive File).  You should see a project called lab6 in the Package Explorer.

Your Tasks

The program consists of two classes: BinPacking and Disk.

First task: change the program so that it displays the number of disks that have been placed in the bin in the upper right hand corner of the screen.  This number should be displayed in black text, and should be visible at all times  For example, if the user places a disk in a part of the screen where current number of disks is displayed, it should not cover up the number.

Second task: remove the limit on the number of disks that may be placed by the user.  As initially written, the game only allows the user to place a fixed number of disks, as specified by the constant MAX_DISKS.  You should change the program so that any number of disks may be placed.  However, you should do this

  1. without adding any new fields to either class, and
  2. without changing the type of any existing field