Class Road

java.lang.Object
  |
  +--Road
All Implemented Interfaces:
uwcse.animation.Prop

public class Road
extends java.lang.Object
implements uwcse.animation.Prop

This class models a roadway in our scene.


Constructor Summary
Road(int x, int y, int width, int height, boolean east_west, int speedLimit)
          Construct the surface and the centerline of the road given the parameters.
 
Method Summary
 void addTo(uwcse.graphics.GWindow g)
          Add the elements of this display object to the graphics window.
 void changeNumberOfCarsBy(int number)
          Change the number of Cars traveling on this Road by the given number
 int getHeight()
          Return the y-span of the Road.
 int getNumberOfCars()
          Return the number of Cars traveling on this Road
 int getSpeedLimit()
          Return the speed limit in pixels per tick for Cars on this Road
 uwcse.graphics.Shape getSurface()
          Return the Shape avatar of the Road.
 int getWidth()
          Return the x-span of the Road.
 int getX()
          Return the x-coordinate of the upper left corner of the Road.
 int getY()
          Return the y-coordinate of the upper left corner of the Road.
 void removeFromWindow()
          Remove the elements of this display object from the graphics window.
 boolean roadIsEastWest()
          Return a boolean regarding orientation of the Road
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Road

public Road(int x,
            int y,
            int width,
            int height,
            boolean east_west,
            int speedLimit)
Construct the surface and the centerline of the road given the parameters.

Parameters:
x - the x-coordinate of the upper left corner of the road
y - the y-coordinate of the upper left corner of the road
width - the x-axis span of the road
height - the y-axis span of the road
east_west - the direction of the road; true means East-West, false means North-South
speedLimit - the integer speed limit for Cars on this Road in pixels per clock tick
Method Detail

addTo

public void addTo(uwcse.graphics.GWindow g)
Add the elements of this display object to the graphics window.

Specified by:
addTo in interface uwcse.animation.Prop
Parameters:
g - the graphics window to use

removeFromWindow

public void removeFromWindow()
Remove the elements of this display object from the graphics window.

Specified by:
removeFromWindow in interface uwcse.animation.Prop

getX

public int getX()
Return the x-coordinate of the upper left corner of the Road.

Returns:
the x-coordinate of the upper left corner of the Road

getY

public int getY()
Return the y-coordinate of the upper left corner of the Road.

Returns:
the y-coordinate of the upper left corner of the Road

getHeight

public int getHeight()
Return the y-span of the Road.

Returns:
the height of the Road

getWidth

public int getWidth()
Return the x-span of the Road.

Returns:
the width of the Road

getSurface

public uwcse.graphics.Shape getSurface()
Return the Shape avatar of the Road.

Returns:
the Shape comprising the Road

roadIsEastWest

public boolean roadIsEastWest()
Return a boolean regarding orientation of the Road

Returns:
true if the Road is oriented East-West, false if oriented North-South

getSpeedLimit

public int getSpeedLimit()
Return the speed limit in pixels per tick for Cars on this Road

Returns:
the integer speed limit for this Road

getNumberOfCars

public int getNumberOfCars()
Return the number of Cars traveling on this Road

Returns:
the integer number of Cars traveling along this Road

changeNumberOfCarsBy

public void changeNumberOfCarsBy(int number)
Change the number of Cars traveling on this Road by the given number

Parameters:
number - the integer # of Cars by which to change this Road's population