-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar.java
More file actions
52 lines (45 loc) · 1.15 KB
/
Car.java
File metadata and controls
52 lines (45 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
/**
* CSCI 6341/ Final Project: Automatic Crossroads Control and Management
* Author: Ismayil Hasanov, Yubo Tsai, Han Wang
* Date : Apr 25 2017
* Description: Vehicles class
*/
class Car implements Comparable {
public static int LEFT = 2;
public static int STRAIGHT = 1;
public static int RIGHT = 0;
//private AIMC aimc;
double arrivalTime;
int direction = -1;
int fromLane = -1;
int carID = -1;
public Car (double arrivalTime, int direction, int fromLane, int carID) {
this.arrivalTime = arrivalTime;
this.direction = direction;
this.fromLane = fromLane;
this.carID = carID;
}
public int compareTo(Object obj)
{
Car car = (Car) obj;
if (arrivalTime < car.arrivalTime) {
return -1;
}
else if (arrivalTime > car.arrivalTime) {
return 1;
}
else {
return 0;
}
}
public boolean equals(Object obj)
{
return (compareTo(obj) == 0);
}
}