Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class car {
- private String registration;
- private int doors;
- private String colour;
- private carDealer supplier;
- private static int totalCars = 0;
- public car() {
- this.registration = null;
- this.doors = 0;
- this.colour = null;
- this.supplier = null;
- ++totalCars;
- }
- public car(
- String registration,
- int doors,
- String colour,
- carDealer supplier
- ){
- this.registration = registration;
- this.doors = doors;
- this.colour = colour;
- this.supplier = supplier;
- ++totalCars;
- }
- public static int getTotalCars() {
- return totalCars;
- }
- public static void setTotalCars(int totalCars) {
- car.totalCars = totalCars;
- }
- public String getColour() {
- return colour;
- }
- public void setColour(String colour) {
- this.colour = colour;
- }
- public void setRegistration(String registration) {
- this.registration = registration;
- }
- public String getRegistration() {
- return registration;
- }
- public carDealer getSupplier() {
- return supplier;
- }
- public void setSupplier(carDealer supplier) {
- this.supplier = supplier;
- }
- }
- package test;
- public class carDealer {
- private String dealerID;
- public carDealer(String dealerID){
- this.dealerID = dealerID;
- }
- }
- package test;
- public class driver {
- public static void main(String[]args){
- for (int = 0; int < 3; i++){
- new car();
- System.out.println(car.getTotalCars());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement