Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. public class car {
  2. private String registration;
  3. private int doors;
  4. private String colour;
  5. private carDealer supplier;
  6. private static int totalCars = 0;
  7. public car() {
  8. this.registration = null;
  9. this.doors = 0;
  10. this.colour = null;
  11. this.supplier = null;
  12. ++totalCars;
  13. }
  14. public car(
  15. String registration,
  16. int doors,
  17. String colour,
  18. carDealer supplier
  19. ){
  20. this.registration = registration;
  21. this.doors = doors;
  22. this.colour = colour;
  23. this.supplier = supplier;
  24. ++totalCars;
  25. }
  26.  
  27. public static int getTotalCars() {
  28. return totalCars;
  29. }
  30.  
  31. public static void setTotalCars(int totalCars) {
  32. car.totalCars = totalCars;
  33. }
  34.  
  35. public String getColour() {
  36. return colour;
  37. }
  38.  
  39. public void setColour(String colour) {
  40. this.colour = colour;
  41. }
  42.  
  43. public void setRegistration(String registration) {
  44. this.registration = registration;
  45. }
  46.  
  47. public String getRegistration() {
  48. return registration;
  49. }
  50.  
  51. public carDealer getSupplier() {
  52. return supplier;
  53. }
  54.  
  55. public void setSupplier(carDealer supplier) {
  56. this.supplier = supplier;
  57. }
  58. }
  59.  
  60.  
  61.  
  62. package test;
  63.  
  64. public class carDealer {
  65. private String dealerID;
  66. public carDealer(String dealerID){
  67. this.dealerID = dealerID;
  68. }
  69.  
  70. }
  71.  
  72.  
  73. package test;
  74.  
  75. public class driver {
  76. public static void main(String[]args){
  77. for (int = 0; int < 3; i++){
  78. new car();
  79. System.out.println(car.getTotalCars());
  80. }
  81. }
  82. }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement