-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitchDirection.java
More file actions
43 lines (36 loc) · 1 KB
/
switchDirection.java
File metadata and controls
43 lines (36 loc) · 1 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
public class switchDirection{
private double throttle;
private double throttle2;
private double throttle1;
private int reverseDirectionCount = 0;
public switchDirection(double throttle1, double throttle2){
this.throttle1 = throttle1;
this.throttle = throttle1;
this.throttle2 = throttle2;
}
public void switchThrottle(){
reverseDirectionCount++;
if(reverseDirectionCount % 2 == 0){
throttle = throttle1;
}
else{
throttle = throttle2;
}
}
public double getThrottle(){
return throttle;
}
public void setThrottle1(double throttle){
this.throttle1 = throttle;
this.throttle = throttle;
reverseDirectionCount = 0;
}
public void setThrottle2(double throttle){
this.throttle2 = throttle;
this.throttle = throttle;
reverseDirectionCount = 1;
}
public String toString(){
return "Throttle: " + throttle;
}
}