Skip to content

Commit 1627189

Browse files
committed
feat: adds Formula1Car methods
1 parent faa4f80 commit 1627189

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package com.codedifferently.lesson16.evanphilakhong;
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
@Configuration
7+
@SpringBootApplication(scanBasePackages = "com.codedifferently")
8+
9+
public class Formula1Car {
10+
private Team team;
11+
private String[] sponsors;
12+
private String driverName;
13+
private int driverNum;
14+
private TyreCompound currTyre;
15+
private boolean isDrs;
16+
17+
//Constructors
18+
public Formula1Car() {
19+
this.team = null;
20+
this.sponsors = new String[0];
21+
this.driverName = "";
22+
this.driverNum = 0;
23+
this.currTyre = null;
24+
this.isDrs = false;
25+
}
26+
27+
public Formula1Car(Team team, String[] sponsors, String driverName, int driverNum, TyreCompound currTyre) {
28+
this.team = team;
29+
this.sponsors = sponsors;
30+
this.driverName = driverName;
31+
this.driverNum = driverNum;
32+
this.currTyre = currTyre;
33+
this.isDrs = false;
34+
}
35+
36+
// setters
37+
public void setTeam(Team team) {
38+
this.team = team;
39+
}
40+
41+
public void setSponsors(String[] sponsors) {
42+
this.sponsors = sponsors;
43+
}
44+
45+
public void setDriverName(String driverName) {
46+
this.driverName = driverName;
47+
}
48+
49+
public void setDriverNum(int driverNum) {
50+
this.driverNum = driverNum;
51+
}
52+
53+
public void setCurrTyre(TyreCompound newTyre) {
54+
this.currTyre = newTyre;
55+
}
56+
57+
public void setIsDrsOn(boolean isDrs) {
58+
this.isDrs = isDrs;
59+
}
60+
61+
// getters
62+
public String getTeam() {
63+
return this.team.toString();
64+
}
65+
66+
public String[] getSponsors() {
67+
return this.sponsors;
68+
}
69+
70+
public String getDriverName() {
71+
return this.driverName;
72+
}
73+
74+
public int getDriverNum() {
75+
return this.driverNum;
76+
}
77+
78+
public TyreCompound getTyreCompound() {
79+
return this.currTyre;
80+
}
81+
82+
public boolean getIsDrsOn() {
83+
return this.isDrs;
84+
}
85+
86+
// methods
87+
public void printSponsors() {
88+
for (String sponsor : sponsors) {
89+
System.out.println(sponsor);
90+
}
91+
}
92+
public static void main(String[] args) {
93+
94+
}
95+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.codedifferently.lesson16.evanphilakhong;
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
@Configuration
7+
@SpringBootApplication(scanBasePackages = "com.codedifferently")
8+
9+
public enum Team {
10+
ALPINE, ASTON_MARTIN, FERRARI, HASS,
11+
MCLAREN, MERCEDES, VCARB, RED_BULL,
12+
SAUBER, WILLIAMS
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.codedifferently.lesson16.evanphilakhong;
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
@Configuration
7+
@SpringBootApplication(scanBasePackages = "com.codedifferently")
8+
9+
enum TyreCompound {
10+
SOFT, MEDIUM, HARD, INTERMEDIATE, WET
11+
}

0 commit comments

Comments
 (0)