CSCI 201

Fall 2001

Assignment 6


Overview

You are given a zipped project folder as your starting point for this assignment; select this link to access that archive file. When you unzip the file, you will find a project folder containing two java files and the associated JCreator bookkeeping files.

The purpose of this program is create ASCII (i.e., text-based as opposed to graphics-based) figures. You are given a class called Figure and a class called Triangle that is derived from Figure. These classes work as follows: A triangle is specified by an offset and a size. The offset determines how far the triangle should be indented from the edge of the screen. The size establishes the width of the base of the triangle. The triangle will point up. The slope of a side of the triangle is limited to what you get by indenting one character per line (if you want to be smooth).

Your Task

Your job is to extend the program to include both a Box class that draws a box, and a Tree class that draws Christmas trees depicted as triangles sitting on top of boxes.

The Box class must be derived from the Figure class. A box should be a rectangular shape and therefore must have both length and width instance variables. It should also be possible to specify the indentation of a box (i.e., its offset) from the edge of the screen. The Box should also contain a reset() method similar to the reset() method in the Triangle class.

The Tree class must draw at least two Christmas trees similar to the one shown below. The two trees must be of different sizes.

                              *
                             * *
                            *   *
                           *     *
                          *       *
                         *         *
                        *************
                             ---
                             | |
                             | |
                             ---

What to Turn In

Turn in the source code for Box and Tree classes (i.e., Box.java and Tree.java). Remember that the files you turn in must have exactly these names. You were shown how to transfer files to your class ftp directory in lab 1, here is a quick refresher.