Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. package inhert;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Player p1 = new Player();
  8. p1.Output();
  9.  
  10. System.out.println("\n");
  11.  
  12. Player p2 = new Player(
  13. "Bob",
  14. "Captain",
  15. "No",
  16. 1234,
  17. (short)99,
  18. (short)12,
  19. 18.9f);
  20.  
  21. p2.Output();
  22.  
  23. System.out.println("\n Subclass: \n");
  24.  
  25. PlayerV2 pv1 = new PlayerV2();
  26. pv1.Output();
  27.  
  28. System.out.println("\n");
  29.  
  30. PlayerV2 pv2 = new PlayerV2(
  31. "Bob",
  32. "Captain",
  33. "No",
  34. 1234,
  35. (short)99,
  36. (short)12,
  37. 18.9f,
  38. (short) 6,
  39. (short) 100,
  40. (short) 50,
  41. (int) 1000,
  42. "Team Snake");
  43.  
  44. pv2.Output();
  45.  
  46. System.out.println("\n");
  47.  
  48. System.out.println(pv1.getRankAndName());
  49. System.out.println(pv2.getRankAndName());
  50. }
  51.  
  52. }
  53.  
  54.  
  55. // don't inherit constructors
  56. // java dosn't support multiple inheritance
  57. // new = new memory for an object
  58. // superclass first sub class is second
  59. // dont use colon but use extend
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement