fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. System.out.println("Hello");
  14. Braille b=new Braille();
  15. CD cd=new CD();
  16. DVD dvd=new DVD();
  17. printMedia(b);
  18. printMedia(cd);
  19. printMedia(dvd);
  20. }
  21.  
  22. public static void printMedia(LibMedia media){
  23. media.borrow();
  24. }
  25. }
  26.  
  27.  
  28.  
  29. interface LibMedia
  30. {
  31. public void borrow();
  32. }
  33.  
  34. class Braille implements LibMedia{
  35. public void borrow(){
  36. System.out.println("Braille");
  37. }
  38. }
  39. class CD implements LibMedia{
  40. public void borrow(){
  41. System.out.println("CD");
  42. }
  43. }
  44. class DVD implements LibMedia{
  45. public void borrow(){
  46. System.out.println("DVD");
  47. }
  48. }
Success #stdin #stdout 0.13s 320576KB
stdin
Standard input is empty
stdout
Hello
Braille
CD
DVD