Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ex1 {
- enum Mes {
- Janeiro,
- Fevereiro,
- Marco;
- public boolean antes(Mes e) {
- if (this == e) return false;
- if (this == Janeiro) return false;
- if (this == Fevereiro && e == Janeiro) return true;
- if (this == Marco && (e == Janeiro || e == Fevereiro)) return true;
- return false;
- }
- };
- public static void main(String[] args) {
- Calendar c = Calendar.getInstance();
- Mes mes = Mes.Fevereiro;
- int m = c.get(MONTH);
- switch(m) {
- case 0: {
- System.out.println(""+ mes.antes(Janeiro));
- }
- case 1: {
- System.out.println(""+ mes.antes(Fevereiro));
- }
- case 2: {
- System.out.println(""+ mes.antes(Marco));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement