-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicle.java
More file actions
executable file
·45 lines (43 loc) · 1.04 KB
/
Vehicle.java
File metadata and controls
executable file
·45 lines (43 loc) · 1.04 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
//Name: Marco Bozic
//Student Number: 500896651
import java.util.*;
//Vehicle Class
public class Vehicle
{
//values for PowerSource
public enum PowerSource
{
GAS_ENGINE, DIESEL_ENGINE, ELECTRIC_MOTOR;
}
//various instance variables
public PowerSource power;
String manuf;
String color;
int numWheels;
int vin;
Random rand = new Random();
public Vehicle()
{
this.manuf = "";
}
//vehicle constructor
public Vehicle(String manuf, String color, int numWheels, PowerSource power)
{
this.manuf = manuf;
this.color = color;
this.numWheels = numWheels;
this.power = power;
vin = rand.nextInt(499-100) + 100;
}
//method used to display information about vehicle
public String display()
{
return vin + " " + manuf + " " + color;
}
//method used to vehicle equal object and other vehicle
public boolean equals(Object other)
{
Vehicle otherV = (Vehicle) other;
return power == otherV.power && manuf.equals(otherV.manuf) && numWheels == otherV.numWheels;
}
}