6
6
@ Getter
7
7
@ Setter
8
8
public class Formula1Car {
9
+ private Track track ;
9
10
private Team team ;
10
11
private String [] sponsors ;
11
12
private String driverName ;
12
13
private int driverNum ;
14
+ private int position ;
13
15
private TyreCompound currTyre ;
14
- private boolean isDrs ;
16
+ private boolean drs ;
15
17
16
18
//Constructors
17
19
public Formula1Car () {
@@ -20,24 +22,45 @@ public Formula1Car() {
20
22
this .driverName = "" ;
21
23
this .driverNum = 0 ;
22
24
this .currTyre = null ;
23
- this .isDrs = false ;
25
+ this .drs = false ;
24
26
}
25
27
26
- public Formula1Car (Team team , String [] sponsors , String driverName , int driverNum , TyreCompound currTyre ) {
28
+ public Formula1Car (Team team , String [] sponsors , String driverName , int driverNum , int position , TyreCompound currTyre ) {
27
29
this .team = team ;
28
30
this .sponsors = sponsors ;
29
31
this .driverName = driverName ;
30
32
this .driverNum = driverNum ;
33
+ this .position = position ;
31
34
this .currTyre = currTyre ;
32
- this .isDrs = false ;
35
+ this .drs = false ;
33
36
}
34
37
35
38
// methods
36
39
public void printSponsors () {
37
- for (String sponsor : sponsors ) {
38
- System .out .println (sponsor );
40
+ if (sponsors .length == 0 ) {
41
+ System .out .println ("There are no Sponsors" );
42
+ } else {
43
+ System .out .println ("Here's a list of our Sponsors:" );
44
+ for (String sponsor : sponsors ) {
45
+ System .out .println (sponsor );
46
+ }
39
47
}
40
48
}
49
+
50
+ public boolean isDrsAvailible () {
51
+ if (track .isDrsZone ()) {
52
+ this .drs = true ;
53
+ return true ;
54
+ }
55
+ return false ;
56
+ }
57
+
58
+ public boolean rainStrategy () {
59
+ if (track .isRaining ()) {
60
+ currTyre .setCurrTyre (TyreCompound .WET );
61
+ }
62
+ }
63
+
41
64
public static void main (String [] args ) {
42
65
Formula1Car formula1Car = new Formula1Car ();
43
66
Team team = Team .MCLAREN ;
0 commit comments