Advertisement
petar088

Untitled

Oct 13th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. package _13_DEFINING_CLASSES.Exercise_Class._5_Car_Salesman_;
  2.  
  3. public class Car {
  4. private String model;
  5. private String engine;
  6. private int weight;
  7. private String color;
  8. private int power;
  9. private int displacement;
  10. private String efficiency;
  11.  
  12. public Car(String model, String engine, int weight, String color,int power, int displacement, String efficiency){
  13. this.model = model;
  14. this.engine = engine;
  15. this .weight = weight;
  16. this.color = color;
  17. this.power = power;
  18. this.displacement = displacement;
  19. this.efficiency = efficiency;
  20. }
  21. public Car(String model, String engine, int weight,int power, int displacement, String efficiency){
  22. this.model = model;
  23. this.engine = engine;
  24. this .weight = weight;
  25. this.color = "n/a";
  26. this.power = power; //When creating the object for a Car, you should keep a reference to the real engine in it
  27. this.displacement = displacement;//, instead of just the engines model,
  28. this.efficiency = efficiency; // note that the optional properties might be missing from the formats.
  29.  
  30. }
  31. public Car(String model, String engine, String color,int power, int displacement, String efficiency){
  32. this.model = model;
  33. this.engine = engine;
  34. this .weight = -1;
  35. this.color = color;
  36. this.power = power;
  37. this.displacement = displacement;
  38. this.efficiency = efficiency;
  39. }
  40. public Car(String model, String engine,int power, int displacement, String efficiency){
  41. this.model = model;
  42. this.engine = engine;
  43. this .weight = -1;
  44. this.color = "n/a";
  45. this.power = power;
  46. this.displacement = displacement;
  47. this.efficiency = efficiency;
  48. }
  49. public String getModel() {
  50. return model;
  51. }
  52.  
  53. public void setModel(String model) {
  54. this.model = model;
  55. }
  56.  
  57. public String getEngine() {
  58. return engine;
  59. }
  60.  
  61. public void setEngine(String engine) {
  62. this.engine = engine;
  63. }
  64.  
  65. public int getWeight() {
  66. return weight;
  67. }
  68.  
  69. public void setWeight(int weight) {
  70. this.weight = weight;
  71. }
  72.  
  73. public String getColor() {
  74. return color;
  75. }
  76.  
  77. public void setColor(String color) {
  78. this.color = color;
  79. }
  80.  
  81. public int getPower() {
  82. return power;
  83. }
  84.  
  85. public void setPower(int power) {
  86. this.power = power;
  87. }
  88.  
  89. public int getDisplacement() {
  90. return displacement;
  91. }
  92.  
  93. public void setDisplacement(int displacement) {
  94. this.displacement = displacement;
  95. }
  96.  
  97. public String getEfficiency() {
  98. return efficiency;
  99. }
  100.  
  101. public void setEfficiency(String efficiency) {
  102. this.efficiency = efficiency;
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement