Паттерн: Фабричный метод (Factory Method)
Исходник: Monitor.java, язык: java [code #421, hits: 8428]
автор: this [добавлен: 13.06.2007]
  1. package factoryMethod;
  2.  
  3. public class Monitor {
  4. protected int screenSize;
  5. protected int weight;
  6. protected float brightness;
  7. public Monitor(int screenSize, int weight, float brightness) {
  8. super();
  9. this.screenSize = screenSize;
  10. this.weight = weight;
  11. this.brightness = brightness;
  12. }
  13. public float getBrightness() {
  14. return brightness;
  15. }
  16. public void setBrightness(float brightness) {
  17. this.brightness = brightness;
  18. }
  19. public int getScreenSize() {
  20. return screenSize;
  21. }
  22. public void setScreenSize(int screenSize) {
  23. this.screenSize = screenSize;
  24. }
  25. public int getWeight() {
  26. return weight;
  27. }
  28. public void setWeight(int weight) {
  29. this.weight = weight;
  30. }
  31. }
Сущность Product
Абстрактный интерфейс продуктов типа монитор.
Тестировалось на: java 1.5.0_04

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