Advertisement
Guest User

class car

a guest
Mar 22nd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. package person;
  2.  
  3. import p2.Helper;
  4.  
  5. public class Car implements Helper {
  6.  
  7.  
  8.  
  9.  
  10. private int speed;
  11.  
  12. public Car(int speed) {
  13.  
  14. this.speed = speed;
  15. }
  16.  
  17. public int getSpeed() {
  18. return speed;
  19. }
  20.  
  21. public void setSpeed(int speed) {
  22. this.speed = speed;
  23. }
  24.  
  25. @Override
  26. public void show2(int c) {
  27. System.out.println(this.speed);
  28.  
  29. }
  30.  
  31.  
  32.  
  33.  
  34. @Override
  35. public int compareTo(Helper o) {
  36. if(this.speed>((Car)o).getSpeed())
  37. return 1;
  38. else if(this.speed<((Car)o).getSpeed())
  39. return -1;
  40.  
  41.  
  42. return 0;
  43. }
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement