Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
Created Enums (Needs work, kinda dry) (I5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreadfall committed Aug 27, 2023
1 parent 9d7bd36 commit e5cb317
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Learning_Materials/Intermediate_Level/Java/I5Enums.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public class I5Enums {
public static void main(String[] args) {
// Enums aren't often as used as the other variables, but we still use them in robotics, so it's
// important to know what they are. They are basically a way to store a set of constants (variables that cannot be changed)

// Here is an example of an enum
enum Direction {
NORTH,
SOUTH,
EAST,
WEST
}
// We know that the direction of a robot can only be one of the four directions, so we can use an enum to store the directions
Direction robotDirection = Direction.NORTH; // robotDirection is now NORTH
robotDirection = Direction.SOUTH; // robotDirection is now SOUTH
// this way, we can't accidentally set robotDirection to something that isn't a direction
}
}

0 comments on commit e5cb317

Please sign in to comment.