Guest User

Untitled

a guest
Dec 15th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. class TestAbstractFactory {
  2.  
  3. public static void main(String args[]) {
  4.  
  5. CarWheelFactory carWheelFactory = new CarWheelFactory();
  6.  
  7. Wheel carWheel = carWheelFactory.makeWheel();
  8. WheelFittingExpert carExpert = carWheelFactory.makeFittingExpert();
  9.  
  10. System.out.println(carWheel.getDescription()); // I am a car wheel
  11. System.out.println(carExpert.getDescription()); // I can only fit car wheels
  12.  
  13.  
  14. // Same for the Bike wheel
  15.  
  16. BikeWheelFactory bikeWheelFactory = new BikeWheelFactory();
  17.  
  18. Wheel bikeWheel = bikeWheelFactory.makeWheel();
  19. WheelFittingExpert bikeExpert = bikeWheelFactory.makeFittingExpert();
  20.  
  21. System.out.println(bikeWheel.getDescription()); // I am a bike wheel
  22. System.out.println(bikeExpert.getDescription()); // I can only fit bike wheels
  23.  
  24. }
  25. }
Add Comment
Please, Sign In to add comment