-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconditionals.java
More file actions
42 lines (31 loc) · 1.05 KB
/
conditionals.java
File metadata and controls
42 lines (31 loc) · 1.05 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
public class Main{
// Run on https://www.tutorialspoint.com/compile_java8_online.php
public static void main(String []args){
int target_distance = 5;
int shooter_range = 10;
int drive_speed = 0;
int flywheel_speed = 0;
if (target_distance < shooter_range) {
drive_speed = 5;
}
if (drive_speed > 0) {
System.out.println("Moving forward");
} else {
System.out.println("Moving backwards");
}
// Set faster shooter speeds for further targets
if (target_distance < 5) {
flywheel_speed = 3; // Slow
} else if (target_distance < 10) {
flywheel_speed = 8; // Fast
} else {
flywheel_speed = 0; // Out of range, turn flywheel off
}
System.out.println("Flywheel speed: "+flywheel_speed);
flywheel_speed = 0;
drive_speed = 0;
if (flywheel_speed == 0 && drive_speed == 0) {
System.out.println("Bot stopped");
}
}
}