You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 23d0c64
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: exercises/concept/need-for-speed/.docs/instructions.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,12 +12,12 @@ You have six tasks, each of which will work with remote controller car instances
12
12
13
13
## 1. Creating a remote controlled car
14
14
15
-
Allow creating a remote controller car by defining a constructor for the `RemoteControlCar` class that takes the speed of the car in meters and the battery drain percentage as its two parameters (both of type `int`):
15
+
Allow creating a remote controller car by defining a constructor for the `NeedForSpeed` class that takes the speed of the car in meters and the battery drain percentage as its two parameters (both of type `int`):
16
16
17
17
```java
18
18
int speed =5;
19
19
int batteryDrain =2;
20
-
var car =newRemoteControlCar(speed, batteryDrain);
20
+
var car =newNeedForSpeed(speed, batteryDrain);
21
21
```
22
22
23
23
## 2. Creating a race track
@@ -31,12 +31,12 @@ var raceTrack = new RaceTrack(distance);
31
31
32
32
## 3. Drive the car
33
33
34
-
Implement the `RemoteControlCar.drive()` method that updates the number of meters driven based on the car's speed. Also implement the `RemoteControlCar.distanceDriven()` method to return the number of meters driven by the car:
34
+
Implement the `NeedForSpeed.drive()` method that updates the number of meters driven based on the car's speed. Also implement the `NeedForSpeed.distanceDriven()` method to return the number of meters driven by the car:
35
35
36
36
```java
37
37
int speed =5;
38
38
int batteryDrain =2;
39
-
var car =newRemoteControlCar(speed, batteryDrain);
39
+
var car =newNeedForSpeed(speed, batteryDrain);
40
40
car.drive();
41
41
42
42
car.distanceDriven();
@@ -45,12 +45,12 @@ car.distanceDriven();
45
45
46
46
## 4. Check for a drained battery
47
47
48
-
Update the `RemoteControlCar.drive()` method to drain the battery based on the car's battery drain. Also implement the `RemoteControlCar.batteryDrained()` method that indicates if the battery is drained:
48
+
Update the `NeedForSpeed.drive()` method to drain the battery based on the car's battery drain. Also implement the `NeedForSpeed.batteryDrained()` method that indicates if the battery is drained:
49
49
50
50
```java
51
51
int speed =5;
52
52
int batteryDrain =2;
53
-
var car =newRemoteControlCar(speed, batteryDrain);
53
+
var car =newNeedForSpeed(speed, batteryDrain);
54
54
car.drive();
55
55
56
56
car.batteryDrained();
@@ -59,23 +59,23 @@ car.batteryDrained();
59
59
60
60
## 5. Create the Nitro remote control car
61
61
62
-
The best-selling remote control car is the Nitro, which has a stunning top speed of 50 meters with a battery drain of 4%. Implement the (static) `RemoteControlCar.nitro()` method to return this type of car:
62
+
The best-selling remote control car is the Nitro, which has a stunning top speed of 50 meters with a battery drain of 4%. Implement the (static) `NeedForSpeed.nitro()` method to return this type of car:
63
63
64
64
```java
65
-
var car =RemoteControlCar.nitro();
65
+
var car =NeedForSpeed.nitro();
66
66
car.drive();
67
67
car.distanceDriven();
68
68
// => 50
69
69
```
70
70
71
71
## 6. Check if a remote control car can finish a race
72
72
73
-
To finish a race, a car has to be able to drive the race's distance. This means not draining its battery before having crossed the finish line. Implement the `Race.carCanFinish()` method that takes a `RemoteControlCar` instance as its parameter and returns `true` if the car can finish the race; otherwise, return `false`:
73
+
To finish a race, a car has to be able to drive the race's distance. This means not draining its battery before having crossed the finish line. Implement the `Race.carCanFinish()` method that takes a `NeedForSpeed` instance as its parameter and returns `true` if the car can finish the race; otherwise, return `false`:
74
74
75
75
```java
76
76
int speed =5;
77
77
int batteryDrain =2;
78
-
var car =newRemoteControlCar(speed, batteryDrain);
0 commit comments