Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package vehicle;
- import java.util.Random;
- public class Car {
- private static int vehicleCounter = 1000;
- public static String CAR_FACTORY_ID = "Michigan";
- private String color;
- private String factory;
- private int carID;
- private int numberOfDoors;
- private int price;
- public Car(){
- Random rndGenerator = new Random();
- vehicleCounter ++;
- color = "NA";
- factory = CAR_FACTORY_ID;
- carID = vehicleCounter;
- numberOfDoors = 0;
- price = 25000 + rndGenerator.nextInt(5001);
- }
- public Car(String color, int numberOfDoors){
- this.color = color;
- this.numberOfDoors = numberOfDoors;
- }
- public static int getVehicleCounter(){
- return vehicleCounter;
- }
- public static void setVehicleCounter(int vehicleCounter){
- Car.vehicleCounter = vehicleCounter;
- }
- public static void classDisplayInfo(){
- System.out.println("");
- System.out.println("-----------------------------------");
- System.out.println("Car Info");
- System.out.println("-----------------------------------");
- System.out.println("CarID:"+"\t\t" + vehicleCounter);
- System.out.println("Factory:"+"\t" + CAR_FACTORY_ID);
- }
- public String getColor() {
- return color;
- }
- public void setColor(String color) {
- this.color = color;
- }
- public int getCarID() {
- return carID;
- }
- public void setCarID(int carID) {
- this.carID = carID;
- }
- public int getNumberOfDoors() {
- return numberOfDoors;
- }
- public void setNumberOfDoors(int numberOfDoors) {
- this.numberOfDoors = numberOfDoors;
- }
- public int getPrice() {
- return price;
- }
- public void setPrice(int price) {
- this.price = price;
- }
- public void displayInfo(){
- System.out.println("");
- System.out.println("-----------------------------------");
- System.out.println("Car Info");
- System.out.println("-----------------------------------");
- System.out.println("CarID:\t\t" + carID);
- System.out.println("Factory:\t" + factory);
- System.out.println("Number of Doors:" + numberOfDoors);
- System.out.println("Color:\t\t" + color);
- System.out.println("Price:\t\t" + price);
- System.out.println("");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement