Advertisement
francesco_ranzato

esercizi 10 e 11

Jan 17th, 2018
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. public class Controllata extends Exception {}
  2. public class NonControllata extends RunTimeException {}
  3.  
  4. public class C {
  5.     // esercizio 11
  6.     public static Object Fun(Collection c) throws Controllata {
  7.       if(c == null) throw new Controllata();
  8.       int i = c.size();
  9.       if(c instanceof Vector && i>2) return ((List)c).get(1);
  10.       if(c instanceof LinkedList && i>0) return ((LinkedList)c).removeFirst();
  11.       throw new NonControllata();
  12.     }
  13.    
  14.     // esercizio 10
  15.     public static void Fun(AbstractButton ab) {
  16.       if(ab instanceof JButton)
  17.           if(ab instanceof BasicArrowButton)
  18.           ((BasicArrowButton)ab).setDirection(SwingConstants.NORTH);
  19.           else ab.setText("pippo");
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement