Паттерн: Абстрактная фабрика (Abstract Factory)
Исходник: Liaz.java, язык: java [code #405, hits: 8859]
автор: this [добавлен: 24.05.2007]
  1. package abstractFactory.rusFleet;
  2.  
  3. import abstractFactory.Bus;
  4. import abstractFactory.Car;
  5.  
  6. public class Liaz extends Bus implements Cloneable {
  7. private boolean ASKP;
  8.  
  9. public Liaz(String number, int passengerNum, boolean askp) {
  10. super(number, 3, 4, passengerNum + 1, 160, passengerNum, false);
  11. ASKP = askp;
  12. }
  13.  
  14. public boolean isASKP() {
  15. return ASKP;
  16. }
  17.  
  18.  
  19. //equals/hashCode/toString >>
  20. public boolean equals(Object o) {
  21. if (!(o instanceof Car)) {
  22. return false;
  23. }
  24.  
  25. if (!(o instanceof Liaz)) {
  26. return o.equals(this);
  27. }
  28.  
  29. Liaz other = (Liaz) o;
  30.  
  31. return (super.equals(o) &&
  32. other.ASKP == ASKP);
  33. }
  34.  
  35. public int hashCode() {
  36. int res = super.hashCode();
  37. res = res * 37 + (ASKP ? 1 : 0);
  38. return res;
  39. }
  40.  
  41. public String toString() {
  42. String res = super.toString();
  43. res += ", ASKP=" + ASKP;
  44. return super.toString();
  45. }
  46.  
  47. }
  48.  
Сущность ConcreteProduct
Русский вариант автобуса.
Тестировалось на: java 1.5.0_04

+добавить реализацию