<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FDesign_Pattern%2FDecorator_Pattern</id>
		<title>Java Tutorial/Design Pattern/Decorator Pattern - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FDesign_Pattern%2FDecorator_Pattern"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Design_Pattern/Decorator_Pattern&amp;action=history"/>
		<updated>2026-04-06T12:21:54Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Design_Pattern/Decorator_Pattern&amp;diff=4460&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Design_Pattern/Decorator_Pattern&amp;diff=4460&amp;oldid=prev"/>
				<updated>2010-06-01T05:02:26Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 05:02, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Design_Pattern/Decorator_Pattern&amp;diff=4459&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Design_Pattern/Decorator_Pattern&amp;diff=4459&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Coffee example using decorators ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
interface Countable {&lt;br /&gt;
  String getName();&lt;br /&gt;
  float getCount();&lt;br /&gt;
}&lt;br /&gt;
class Book implements Countable {&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return &amp;quot;Book&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
  public float getCount() {&lt;br /&gt;
    return 0;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
abstract class Number implements Countable {&lt;br /&gt;
  protected Countable component;&lt;br /&gt;
  Number(Countable component) {&lt;br /&gt;
    this.ruponent = component;&lt;br /&gt;
  }&lt;br /&gt;
  public float getCount() {&lt;br /&gt;
    return component.getCount();&lt;br /&gt;
  }&lt;br /&gt;
  public abstract String getName();&lt;br /&gt;
}&lt;br /&gt;
class Integer extends Number {&lt;br /&gt;
  private float value = 0.75f;&lt;br /&gt;
  private String description = &amp;quot; integer&amp;quot;;&lt;br /&gt;
  public Integer(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public float getCount() {&lt;br /&gt;
    return component.getCount() + value;&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Float extends Number {&lt;br /&gt;
  private String description = &amp;quot; float&amp;quot;;&lt;br /&gt;
  public Float(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Double extends Number {&lt;br /&gt;
  private float value = 0.25f;&lt;br /&gt;
  private String description = &amp;quot; double&amp;quot;;&lt;br /&gt;
  public Double(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public float getCount() {&lt;br /&gt;
    return component.getCount() + value;&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Decimal extends Number {&lt;br /&gt;
  private float value = 0.25f;&lt;br /&gt;
  private String description = &amp;quot; decimal&amp;quot;;&lt;br /&gt;
  public Decimal(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public float getCount() {&lt;br /&gt;
    return component.getCount() + value;&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Positive extends Number {&lt;br /&gt;
  private float cost = 0.25f;&lt;br /&gt;
  private String description = &amp;quot; positive&amp;quot;;&lt;br /&gt;
  public Positive(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public float getCount() {&lt;br /&gt;
    return component.getCount() + cost;&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Negative extends Number {&lt;br /&gt;
  private float value = -0.25f;&lt;br /&gt;
  private String description = &amp;quot; negative&amp;quot;;&lt;br /&gt;
  public Negative(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public float getCount() {&lt;br /&gt;
    return component.getCount() + value;&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class NumberCountableDemo {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Countable cappuccino = new Integer(new Double(new Book()));&lt;br /&gt;
    System.out.println(cappuccino.getName().trim() + &amp;quot;: $&amp;quot; + cappuccino.getCount());&lt;br /&gt;
    Countable cafeMocha = new Integer(new Decimal(new Negative(new Positive(new Float(&lt;br /&gt;
        new Book())))));&lt;br /&gt;
    System.out.println(cafeMocha.getName().trim() + &amp;quot;: $&amp;quot; + cafeMocha.getCount());&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  combinations and decorators ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
interface Countable {&lt;br /&gt;
  float getValue();&lt;br /&gt;
  String getName();&lt;br /&gt;
}&lt;br /&gt;
class Book implements Countable {&lt;br /&gt;
  private String description = &amp;quot;books&amp;quot;;&lt;br /&gt;
  private float value = 0.75f;&lt;br /&gt;
  public float getValue() {&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Dog implements Countable {&lt;br /&gt;
  private String description = &amp;quot;dogs&amp;quot;;&lt;br /&gt;
  private float cost = 1;&lt;br /&gt;
  public float getValue() {&lt;br /&gt;
    return cost;&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Cat implements Countable {&lt;br /&gt;
  private float cost = 1;&lt;br /&gt;
  private String description = &amp;quot;Cat&amp;quot;;&lt;br /&gt;
  public float getValue() {&lt;br /&gt;
    return cost;&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Child implements Countable {&lt;br /&gt;
  private float cost = 1;&lt;br /&gt;
  private String description = &amp;quot;child&amp;quot;;&lt;br /&gt;
  public float getValue() {&lt;br /&gt;
    return cost;&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Cow implements Countable {&lt;br /&gt;
  private float cost = 1.25f;&lt;br /&gt;
  private String description = &amp;quot;Cow&amp;quot;;&lt;br /&gt;
  public float getValue() {&lt;br /&gt;
    return cost;&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return description;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
abstract class Number implements Countable {&lt;br /&gt;
  protected Countable component;&lt;br /&gt;
  public Number(Countable component) {&lt;br /&gt;
    this.ruponent = component;&lt;br /&gt;
  }&lt;br /&gt;
  public float getValue() {&lt;br /&gt;
    return component.getValue();&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MyBook extends Number {&lt;br /&gt;
  private float cost = 0.75f;&lt;br /&gt;
  public MyBook(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + &amp;quot; my books&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
  public float getValue() {&lt;br /&gt;
    return cost + component.getValue();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Integer extends Number {&lt;br /&gt;
  private float cost = 0.50f;&lt;br /&gt;
  public Integer(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public float getValue() {&lt;br /&gt;
    return cost + component.getValue();&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + &amp;quot; integer&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Float extends Number {&lt;br /&gt;
  public Float(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + &amp;quot; float&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Double extends Number {&lt;br /&gt;
  public Double(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + &amp;quot; double&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Decimal extends Number {&lt;br /&gt;
  public Decimal(Countable component) {&lt;br /&gt;
    super(component);&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return component.getName() + &amp;quot; decimal&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class CountableDemo {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Countable cappuccino = new Cat();&lt;br /&gt;
    System.out.println(cappuccino.getName() + &amp;quot;: $&amp;quot; + cappuccino.getValue());&lt;br /&gt;
    Countable cafeMocha = new Integer(new Float(new Cow()));&lt;br /&gt;
    System.out.println(cafeMocha.getName() + &amp;quot;: $&amp;quot; + cafeMocha.getValue());&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Creating and Extending Objects with the Decorator Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Computer computer = new Computer();&lt;br /&gt;
    computer = new Disk(computer);&lt;br /&gt;
    computer = new Monitor(computer);&lt;br /&gt;
    computer = new CD(computer);&lt;br /&gt;
    computer = new CD(computer);&lt;br /&gt;
    System.out.println(&amp;quot;You&amp;quot;re getting a &amp;quot; + computer.description() + &amp;quot;.&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Disk extends ComponentDecorator {&lt;br /&gt;
  Computer computer;&lt;br /&gt;
  public Disk(Computer c) {&lt;br /&gt;
    computer = c;&lt;br /&gt;
  }&lt;br /&gt;
  public String description() {&lt;br /&gt;
    return computer.description() + &amp;quot; and a disk&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class CD extends ComponentDecorator {&lt;br /&gt;
  Computer computer;&lt;br /&gt;
  public CD(Computer c) {&lt;br /&gt;
    computer = c;&lt;br /&gt;
  }&lt;br /&gt;
  public String description() {&lt;br /&gt;
    return computer.description() + &amp;quot; and a CD&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Computer {&lt;br /&gt;
  public Computer() {&lt;br /&gt;
  }&lt;br /&gt;
  public String description() {&lt;br /&gt;
    return &amp;quot;computer&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
abstract class ComponentDecorator extends Computer {&lt;br /&gt;
  public abstract String description();&lt;br /&gt;
}&lt;br /&gt;
class Monitor extends ComponentDecorator {&lt;br /&gt;
  Computer computer;&lt;br /&gt;
  public Monitor(Computer c) {&lt;br /&gt;
    computer = c;&lt;br /&gt;
  }&lt;br /&gt;
  public String description() {&lt;br /&gt;
    return computer.description() + &amp;quot; and a monitor&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>