This assignment and all subsequent assignments are to be done with your homework partner.
colors.jar
, geometry.jar
, and
draw.jar
in your EclipseJars folder (on your toaster drive or your
own computer). When you create your Eclipse project you will need to add each
of these libraries as "external jars" along with the tester library.
You can find documentation for the classes provided by these libraries
here.
Follow the links from the "draw" and "colors" libraries to the Javadocs
(Java documentation) for draw
, colors
, and geometry
. You will need import statements for any .java file that refers to a
class that is defined in one of the libraries. Here are the import statements
you will be using:
import colors.*; // when you need to use an IColor import geometry.*; // when you need to use a Posn import draw.*; // when you need to use a draw method, or a Canvas import tester.*; // when you need to use checkExpect, checkInexact, or Tester
There are a couple of reasons why we are restricting your use of Java in these ways. First, we want you to understand Java's dynamic-dispatch mechanism (polymorphism) which is at the heart of object-oriented programming. Let Java figure out types of objects for you! Secondly, we want to avoid assignment statements for the time being, because (as we began to discover in CS 1101) assignments introduce side-effects, making testing more difficult. When we get to problems that can't be solved any other way, we will then use assignment.
Draw a class diagram of a class hierarchy that represent shapes. You won't be submitting it, but you should always start by drawing a class diagram. If you come for office hour help, we will ask you to show us your diagram.
Define a class CartPt to represent a Cartesian point with integer coordinates.
Define the classes that represent the various shapes. Use the CartPt class to represent the positions of shapes. Use the IColor interface to represent the colors of the shapes.
Make examples of data.
Math.sqrt(x)
Canvas c = new Canvas(100, 100); boolean showShape = this.c.show() && this.myShape.draw(this.c);where myShape is an example of a shape that has been defined in the Examples class.
Using web-based turnin, turn in a single file containing all code and documentation for this assignment. Follow the naming conventions when naming your file. Both partners' names and wpi login names should appear in a comment at the top of the file.