Morphing a Polygon
Design the following methods for the classes that represent polygon data that you have defined in the previous two assignments:
Count the number of points in the polygon. (Method name
count
)
Produce a morphed polygon from two original ones, with the
given morphing factor (a number between 0.0and 1.0). Make sure
you follow the one task, one method rule. (Method name
morphPoly
)
Draw the polygon on the Canvas c
. (Method name
drawPoly
) Use a sample
program that
uses the draw
library as a guide - or consult the
Help Desk.
City Map
We continue designing classes that help us draw the city map
and its attractions. For this problem you do not need any of the
classes from the previous assignment, other than the class
Place
that represents a location on the map.
Develop the data definition to represent a route through the city. We are especially interested in being able to locate specific intersections of streets, or named squares, plazas. etc. and to deal with city streets.
Design the class Xing
that represents an intersection
on a city map. It should include a name and the location information.
Next we need to define the class that represents a segment of the street that connects two intersections. For each street segment we need to know the name of the street and its starting and ending intersection.
Design the class Road
to represent one street segment.
Finally, we need a list of street segments that may represent either a routing in the directions generated by a map program, or the list may represent one street in the city.
Design the classes to represent a list of Road
s —
call it a Route
.
Design the method that determines the distance each
Road
covers. (Method name roadLength
)
Design the method that computes the length of a Route
.
(Method name routeLength
)
A Route
provided by a map program must have the street
segments connected to each other — i.e. next segment must start
where the previous one ended. Design the method isRoute
that determines whether a Route
represents valid map
directions.
A street in a city not only consists of adjacent street
segments, but additionally, every segment has the same street
name. Design the method isStreet
that determines whether a
Route
represents a valid city street data.
Optional
Design the methods and classes that will draw each of the intersections as a black dot and will draw the streets as well. You do not need to add the names to the map — simple dots and black lines are fine.