/* * Car.java * * Created on January 8, 2008, 1:05 PM */ package jlsim; import javax.swing.colorchooser.*; import java.awt.*; import java.awt.geom.*; import java.awt.event.*; import javax.swing.*; import java.lang.*; import java.util.*; /** * * @author jliu2 */ public class Car extends java.lang.Object { private double velocity; private double acceleration; private Color color; //Sizes range from 1 to 3, 1 being a small car, 2 being suv, 3 being truck private int carsize; private int xpos; private int ypos; private int width; private int length; private int temp; private boolean orientation; //Either horizontal or vertical orientation //false (0) = horizontal //true (1) = vertical /* Size: Small(1) Medium(2) Large (3) * 18x6 20x8 22x10 *(assuming horizontal orientation)*/ /** Creates a new instance of Car */ public Car() { velocity=0; acceleration=0; color=Color.ORANGE; carsize=1; } public Car(double v, double a) { velocity=a; acceleration=a; color=Color.ORANGE; carsize=1; } public Car(double v, double a, Color c, int size) { velocity=v; acceleration=a; color = c; carsize= size; } public Car(double v, double a, Color c, int size,String keyword2, int x, int y, boolean o) { velocity=v; acceleration=a; color = c; carsize = size; xpos= x; ypos= y; if(keyword2 == "slow") { velocity= 10; acceleration= 2; } if(keyword2 == "medium") { velocity= 15; acceleration= 3; } if(keyword2 == "fast") { velocity= 20; acceleration= 4; } orientation=o; if(size==1) { width=18; length=6; } if(size==2) { width=20; length=8; } if(size==3) { width=22; length=10; } if(orientation==true) { temp= width; width=length; length=temp; } } public double getVelocity() { return this.velocity; } public double getAcceleration() { return this.acceleration; } public Color getColor() { return this.color; } public int getCarSize() { return this.carsize; } public int getCarXPos() { return this.xpos; } public int getCarYPos() { return this.ypos; } public boolean getOrientation() { return this.orientation; } public int getWidth() { return this.width; } public int getLength() { return this.length; } public void setVelocity(double v) { this.velocity= v; } public void setAcceleration(double a) { this.acceleration= a; } public void setColor(Color c) { this.color = c; } public void setCarSize(int size) { this.carsize = size; } public void setCarXPos(int x) { this.xpos = x; } public void setCarYPos(int y) { this.ypos = y; } public void setCarPos(int x,int y) { this.xpos = x; this.ypos = y; } public void setOrientation(boolean o) { orientation = o; } }