This assignment and all subsequent assignments are to be done with your homework partner.
// PROBLEM 1 (class definition for City goes here) (class definition for Location goes here) (class hierarchy for list of cities goes here) (class hierarchy for list of strings goes here)
Examples class should be the last class in your file.
Organize your examples in order in which the homework assignment asks for them,
and clearly label each set of examples with a comment; for example:
class Examples{
Examples(){
}
// PROBLEM 1 - EXAMPLES OF DATA
// Examples of Locations
// Examples of Cities
// Examples of lists of cities
// Examples of lists of strings
// PROBLEM 2 - EXAMPLES OF DATA
// Examples of Cartesian Points
// Examples of Shapes
// PROBLEM 3 - TESTING METHODS
// test toPosn
// test distanceTo
// test contains
// test draw
}
Define a class hierarchy to represent a list of cities. Make examples of data.
Define a class hierarchy that represents a list of strings (this data definition could be used to represent a list of states, where each state is identified by a two-letter string). Make examples of data.
*Design Recipe for Data Definitions
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 shapes. Use the CartPt class to represent the positions of shapes. Use the IColor class to represent the colors of the shapes. Use the Helpdesk in DrScheme to learn how to access the ProfessorJ colors library (Teachpacks/HtDC Teachpacks).
Make examples of data.
Design the method toPosn that produces an instance of the class Posn from this CartPt. The Posn class is defined in the ProfessorJ geometry library (look in the Helpdesk for information about the geometry library).
Design the method distanceTo() that computes the distance (a double) from this CartPt to the given CartPt.
Design the method contains() that determines whether this shape contains the given CartPt. (Note: To do this correctly for the class Line requires a bit of geometrical computation. You are allowed to substitute, in this case, a method that produces false for all inputs.)
Design the method draw() that draws this shape on the given Canvas (refer to the documentation in the draw library on Canvas). You can display shapes on a Canvas by providing statements such as the following in your Examples class:
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.
*Design Recipe for Methods
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.