Advertisement
whiplk

Ex1

Mar 27th, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. public class Ex1 {
  2.  
  3.     enum Mes {
  4.         Janeiro,
  5.         Fevereiro,
  6.         Marco;
  7.        
  8.         public boolean antes(Mes e) {
  9.             if (this == e) return false;
  10.             if (this == Janeiro) return false;
  11.             if (this == Fevereiro && e == Janeiro) return true;
  12.             if (this == Marco && (e == Janeiro || e == Fevereiro)) return true;
  13.            
  14.             return false;
  15.         }
  16.     };
  17.  
  18.     public static void main(String[] args) {
  19.         Calendar c = Calendar.getInstance();
  20.         Mes mes = Mes.Fevereiro;
  21.         int m = c.get(MONTH);
  22.         switch(m) {
  23.             case 0: {
  24.                 System.out.println(""+ mes.antes(Janeiro));
  25.             }
  26.             case 1: {
  27.                 System.out.println(""+ mes.antes(Fevereiro));
  28.             }
  29.             case 2: {
  30.                 System.out.println(""+ mes.antes(Marco));
  31.             }
  32.         }
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement