fork download
  1.  
  2. class Ideone
  3. {
  4. public static void main (String[] args) throws java.lang.Exception
  5. {
  6.  
  7. Train2 ko = new Train2(50);
  8. Express azusa = new Express(100);
  9. run(ko);
  10. run(azusa);
  11. }
  12.  
  13. public static void run(Train2 t) {
  14. t.up();
  15. t.print();
  16. }
  17. }
  18. // your code goes here
  19.  
  20. class Train {
  21. public int speed;
  22.  
  23. public void up() {
  24. speed += 1;
  25. }
  26.  
  27. public void down() {
  28. speed -= 1;
  29. }
  30. }
  31. class Train2 {
  32. protected int speed;
  33.  
  34. public Train2(int s) {
  35. this.speed = s;
  36. }
  37.  
  38. public int getSpeed() {
  39. return speed;
  40. }
  41.  
  42. public void up() {
  43. speed += 1;
  44. }
  45.  
  46. public void print() {
  47. System.out.println(speed);
  48. }
  49. }
  50.  
  51. class Express extends Train2 {
  52. public Express(int ss) {
  53. super(ss);
  54. System.out.println("Express");
  55. }
  56.  
  57. public void up() {
  58. speed += 5;
  59. }
  60.  
  61. }
  62.  
  63.  
Success #stdin #stdout 0.08s 54704KB
stdin
Standard input is empty
stdout
Express
51
105