clanecollege

Car.java

May 17th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.05 KB | None | 0 0
  1. public class Car
  2. {
  3.     private double price;
  4.     private int brakeHorsePower;
  5.     private String regPlate;
  6.     private int numSeats;
  7.     private String manufacturerName;
  8.     private String model;
  9.     private String name;
  10.     private String colour;
  11.  
  12.     // constructor with params
  13.     public Car(double p, int bHP, String rP, int nS, String mN, String m,
  14.             String n, String c)
  15.     {
  16.         this.price = p;
  17.         this.brakeHorsePower = bHP;
  18.         this.regPlate = rP;
  19.         this.numSeats = nS;
  20.         this.manufacturerName = mN;
  21.         this.model = m;
  22.         this.name = n;
  23.         this.colour = c;
  24.     }
  25.  
  26.     // constructor without params
  27.     public Car()
  28.     {
  29.         this.price = 3300.0;
  30.         this.brakeHorsePower = 15;
  31.         this.regPlate = "99-KY-DEFAULT";
  32.         this.numSeats = 4;
  33.         this.manufacturerName = "Ford";
  34.         this.model = "Model T";
  35.         this.name = "EXAMPLE_RANDOM_STRING_VIN_UUID";
  36.         this.colour = "Ultra-Green";
  37.     }
  38.  
  39.     public double getPrice()
  40.     {
  41.         return price;
  42.     }
  43.  
  44.     public void setPrice(double price)
  45.     {
  46.         this.price = price;
  47.     }
  48.  
  49.     public int getBrakeHorsePower()
  50.     {
  51.         return brakeHorsePower;
  52.     }
  53.  
  54.     public void setBrakeHorsePower(int brakeHorsePower)
  55.     {
  56.         this.brakeHorsePower = brakeHorsePower;
  57.     }
  58.  
  59.     public String getRegPlate()
  60.     {
  61.         return regPlate;
  62.     }
  63.  
  64.     public void setRegPlate(String regPlate)
  65.     {
  66.         this.regPlate = regPlate;
  67.     }
  68.  
  69.     public int getNumSeats()
  70.     {
  71.         return numSeats;
  72.     }
  73.  
  74.     public void setNumSeats(int numSeats)
  75.     {
  76.         this.numSeats = numSeats;
  77.     }
  78.  
  79.     public String getManufacturerName()
  80.     {
  81.         return manufacturerName;
  82.     }
  83.  
  84.     public void setManufacturerName(String manufacturerName)
  85.     {
  86.         this.manufacturerName = manufacturerName;
  87.     }
  88.  
  89.     public String getModel()
  90.     {
  91.         return model;
  92.     }
  93.  
  94.     public void setModel(String model)
  95.     {
  96.         this.model = model;
  97.     }
  98.  
  99.     public String getName()
  100.     {
  101.         return name;
  102.     }
  103.  
  104.     public void setName(String name)
  105.     {
  106.         this.name = name;
  107.     }
  108.  
  109.     public String getColour()
  110.     {
  111.         return colour;
  112.     }
  113.  
  114.     public void setColour(String colour)
  115.     {
  116.         this.colour = colour;
  117.     }
  118.  
  119.     public void printDetails()
  120.     {
  121.         System.out.println("******** Car: " + name + " ********");
  122.         System.out.println("Manufacturer Name: " + manufacturerName
  123.                 + "\nModel: " + model + "\nPrice: " + price + "\nBHP: "
  124.                 + brakeHorsePower + "\nRegistration Plate: " + regPlate
  125.                 + "\nNumber of Seats: " + numSeats + "\nColour: " + colour);
  126.         System.out.println("**********************************\n");
  127.     }
  128.  
  129.     public void printPrice()
  130.     {
  131.         System.out.println("Price: " + price);
  132.     }
  133.  
  134.     public void printBHP()
  135.     {
  136.         System.out.println("BHP: " + brakeHorsePower);
  137.     }
  138.  
  139.     public void printRegPlate()
  140.     {
  141.         System.out.println("Registration Plate: " + regPlate);
  142.     }
  143.  
  144.     public void printNumSeats()
  145.     {
  146.         System.out.println("Seats: " + numSeats);
  147.     }
  148.  
  149.     public void printManufacturerName()
  150.     {
  151.         System.out.println("Manufacturer Name: " + manufacturerName);
  152.     }
  153.  
  154.     public void printModel()
  155.     {
  156.         System.out.println("Model: " + model);
  157.     }
  158.  
  159.     public void printName()
  160.     {
  161.         System.out.println("Name: " + name);
  162.     }
  163.  
  164.     public void printColour()
  165.     {
  166.         System.out.println("Colour: " + colour);
  167.     }
  168.  
  169. }
Advertisement
Add Comment
Please, Sign In to add comment