public class Car extends java.lang.Object implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private java.awt.Rectangle |
body |
private java.awt.geom.Ellipse2D.Double |
frontTire |
private java.awt.geom.Ellipse2D.Double |
rearTire |
private java.awt.Rectangle |
roof |
private static long |
serialVersionUID |
Constructor and Description |
---|
Car(int x,
int y,
int width)
Constructs a car.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(java.awt.Graphics2D g2)
Draws the car.
|
private static java.lang.String |
formatRectangularShape(java.awt.geom.RectangularShape s)
A helper method to format a rectangular shape.
|
private void |
readObject(java.io.ObjectInputStream in) |
private static void |
readRectangularShape(java.io.ObjectInputStream in,
java.awt.geom.RectangularShape s)
A helper method to read a rectangular shape.
|
java.lang.String |
toString() |
private void |
writeObject(java.io.ObjectOutputStream out) |
private static void |
writeRectangularShape(java.io.ObjectOutputStream out,
java.awt.geom.RectangularShape s)
A helper method to write a rectangular shape.
|
private static final long serialVersionUID
private java.awt.Rectangle body
private java.awt.Rectangle roof
private transient java.awt.geom.Ellipse2D.Double frontTire
private transient java.awt.geom.Ellipse2D.Double rearTire
public Car(int x, int y, int width)
x
- the left of the bounding rectangley
- the top of the bounding rectanglewidth
- the width of the bounding rectangleprivate void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
java.io.IOException
private static void writeRectangularShape(java.io.ObjectOutputStream out, java.awt.geom.RectangularShape s) throws java.io.IOException
out
- the stream onto which to write the shapes
- the shape to writejava.io.IOException
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
private static void readRectangularShape(java.io.ObjectInputStream in, java.awt.geom.RectangularShape s) throws java.io.IOException
in
- the stream from which to read the shapes
- the shape to read. The method sets the frame
of this rectangular shape.java.io.IOException
public void draw(java.awt.Graphics2D g2)
g2
- the graphics contextpublic java.lang.String toString()
toString
in class java.lang.Object
private static java.lang.String formatRectangularShape(java.awt.geom.RectangularShape s)
s
- the shape to format