Repository navigation
Expand file tree
/
Copy pathCar.java
More file actions
67 lines (62 loc) · 1.72 KB
/
Copy pathCar.java
File metadata and controls
67 lines (62 loc) · 1.72 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package repo; /*Indicates to the compiler that Car class belongs in repo package*/
public class Car{
/* Member Variables ********************************************************************/
private int doors;
private int wheels;
private String model;
private String engine;
private String colour;
/****************************************************************************************/
/* Methods *****************************************************************************/
/* Constructors ****************************************************/
public Car(){
doors = 0;
wheels = 0;
model = "";
engine = "";
colour = "";
}
public Car(int numDoors, int numWheels, String theModel, String sizeEngine, String theColour){
doors = numDoors;
wheels = numWheels;
model = theModel;
engine = sizeEngine;
colour = theColour;
}
/* Setters *********************************************************/
public void setDoors(int doors){
this.doors = doors;
}
public void setWheels(int wheels){
this.wheels = wheels;
}
public void setModel(String model){
this.model = model;
}
public void setEngine(String newValue){
engine = newValue;
}
public void setColour(String newValue){
colour = newValue;
}
/* getters ********************************************************/
public int getDoors(){
return this.doors;
}
public int getWheels(){
return this.wheels;
}
public String getModel(){
return this.model;
}
public String getEngine(){
return this.engine;
}
public String getColour(){
return this.colour;
}
/* Print function */
public void printCarInfo(){
System.out.println("doors: " + doors + ", wheels: " + wheels + ", model: " + model + ", engine: " + engine + ", colour: " + colour);
}
}