Esempio n. 1
0
 public static void perform(Object speaker) {
   Class<?> spkr = speaker.getClass();
   try {
     try {
       Method speak = spkr.getMethod("speak");
       speak.invoke(speaker);
     } catch (NoSuchMethodException e) {
       print(speaker + " cannot speak");
     }
     try {
       Method sit = spkr.getMethod("sit");
       sit.invoke(speaker);
     } catch (NoSuchMethodException e) {
       print(speaker + " cannot sit");
     }
   } catch (Exception e) {
     throw new RuntimeException(speaker.toString(), e);
   }
 }