Advertisement
Guest User

Enum Example

a guest
Oct 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. enum Move {
  2.         ROCK, PAPER, SCISSORS;
  3. }
  4.  
  5. class Hand {
  6.     Move currentMove;
  7.    
  8.     public void setMove(Move currentMove) {
  9.         this.currentMove = currentMove;
  10.     }
  11.    
  12.     public void printCurrentMove() {
  13.         System.out.println(currentMove);
  14.     }
  15. }
  16.  
  17. public class Program {
  18.     public static void main(String args[]) {
  19.         Hand alex = new Hand();
  20.         Hand jared = new Hand();
  21.        
  22.         alex.setMove(Move.ROCK);
  23.         alex.printCurrentMove();
  24.        
  25.         jared.setMove(Move.PAPER);
  26.         jared.printCurrentMove();
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement