Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package car;
  7.  
  8. /**
  9. *
  10. * @author 01603679
  11. */
  12. public class Car {
  13.  
  14. static int carsCreated;
  15. String model;
  16. int year = 21;
  17.  
  18. public Car()
  19. {
  20.  
  21. }
  22. public Car(String Model, int Year)
  23. {
  24. model = Model;
  25. year = Year;
  26. carsCreated++;
  27. }
  28. public Car(Car copycar)
  29. { copycar.setModel(model);
  30. copycar.setYear(year);}
  31. //Constructors
  32. public void setYear(int Year){year = Year;}
  33. public void setModel(String Model){model = Model;}
  34. //Retrivers
  35. public int getYear(){return year;}
  36. public String getModel(){return model;}
  37.  
  38. public String toString()
  39. {
  40. String ret ="dsfa";
  41. return ret;
  42.  
  43. }
  44. public boolean equals(Car car1, Car car2)
  45. {Boolean ans = true;
  46. return (model.equals(car2.getModel()) && year==(car2.getYear()));}
  47.  
  48. public static void main(String[] args) {
  49.  
  50. Car c1 = new Car();
  51. c1.setYear(2011);
  52. c1.setModel("Outback");
  53.  
  54.  
  55. Car c2 = new Car("Prisim", 1998);
  56. Car copy1 = new Car(c1);
  57.  
  58. System.out.println(c1.getModel());
  59. System.out.println(c1.getYear());
  60. System.out.println(c2.getModel());
  61. System.out.println(copy1.getModel());
  62. // TODO code application logic here
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement