Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. package vehicle;
  2. import java.util.Random;
  3.  
  4. public class Car {
  5.  
  6. private static int vehicleCounter = 1000;
  7. public static String CAR_FACTORY_ID = "Michigan";
  8.  
  9. private String color;
  10. private String factory;
  11. private int carID;
  12. private int numberOfDoors;
  13. private int price;
  14.  
  15.  
  16. public Car(){
  17. Random rndGenerator = new Random();
  18. vehicleCounter ++;
  19. color = "NA";
  20. factory = CAR_FACTORY_ID;
  21. carID = vehicleCounter;
  22. numberOfDoors = 0;
  23. price = 25000 + rndGenerator.nextInt(5001);
  24.  
  25.  
  26. }
  27.  
  28. public Car(String color, int numberOfDoors){
  29. this.color = color;
  30. this.numberOfDoors = numberOfDoors;
  31. }
  32. public static int getVehicleCounter(){
  33. return vehicleCounter;
  34. }
  35. public static void setVehicleCounter(int vehicleCounter){
  36. Car.vehicleCounter = vehicleCounter;
  37. }
  38. public static void classDisplayInfo(){
  39. System.out.println("");
  40. System.out.println("-----------------------------------");
  41. System.out.println("Car Info");
  42. System.out.println("-----------------------------------");
  43. System.out.println("CarID:"+"\t\t" + vehicleCounter);
  44. System.out.println("Factory:"+"\t" + CAR_FACTORY_ID);
  45. }
  46.  
  47. public String getColor() {
  48. return color;
  49. }
  50.  
  51. public void setColor(String color) {
  52. this.color = color;
  53. }
  54.  
  55. public int getCarID() {
  56. return carID;
  57. }
  58.  
  59. public void setCarID(int carID) {
  60. this.carID = carID;
  61. }
  62.  
  63. public int getNumberOfDoors() {
  64. return numberOfDoors;
  65. }
  66.  
  67. public void setNumberOfDoors(int numberOfDoors) {
  68. this.numberOfDoors = numberOfDoors;
  69. }
  70.  
  71. public int getPrice() {
  72. return price;
  73. }
  74.  
  75. public void setPrice(int price) {
  76. this.price = price;
  77. }
  78.  
  79.  
  80. public void displayInfo(){
  81. System.out.println("");
  82. System.out.println("-----------------------------------");
  83. System.out.println("Car Info");
  84. System.out.println("-----------------------------------");
  85. System.out.println("CarID:\t\t" + carID);
  86. System.out.println("Factory:\t" + factory);
  87. System.out.println("Number of Doors:" + numberOfDoors);
  88. System.out.println("Color:\t\t" + color);
  89. System.out.println("Price:\t\t" + price);
  90. System.out.println("");
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement