2014-08-13 21:14:03 +03:00
|
|
|
package com.iluwatar;
|
|
|
|
|
2014-08-31 09:03:10 +03:00
|
|
|
/**
|
2014-10-08 13:42:12 +01:00
|
|
|
*
|
2014-10-07 16:23:37 +01:00
|
|
|
* With Composite we can treat tree hierarchies of objects with uniform
|
|
|
|
* interface (LetterComposite). In this example we have sentences composed of
|
|
|
|
* words composed of letters.
|
2014-10-08 13:42:12 +01:00
|
|
|
*
|
2014-08-31 09:03:10 +03:00
|
|
|
*/
|
2014-10-07 16:23:37 +01:00
|
|
|
public class App {
|
|
|
|
|
2014-10-08 13:42:12 +01:00
|
|
|
public static void main(String[] args) {
|
|
|
|
System.out.println("Message from the orcs: ");
|
2014-10-07 16:23:37 +01:00
|
|
|
|
2014-10-08 13:42:12 +01:00
|
|
|
LetterComposite orcMessage = new Messenger().messageFromOrcs();
|
|
|
|
orcMessage.print();
|
2014-10-07 16:23:37 +01:00
|
|
|
|
2014-10-08 13:42:12 +01:00
|
|
|
System.out.println("\n");
|
2014-10-07 16:23:37 +01:00
|
|
|
|
2014-10-08 13:42:12 +01:00
|
|
|
System.out.println("Message from the elves: ");
|
2014-08-13 21:14:03 +03:00
|
|
|
|
2014-10-08 13:42:12 +01:00
|
|
|
LetterComposite elfMessage = new Messenger().messageFromElves();
|
|
|
|
elfMessage.print();
|
|
|
|
}
|
2014-08-13 21:14:03 +03:00
|
|
|
}
|