コード例 #1
0
ファイル: Client.java プロジェクト: guomi2004/guomi
  /** @param args */
  public static void main(String[] args) {
    int i = 20;

    FlyweightFactory factory = new FlyweightFactory();
    Flyweight flyweight1 = factory.getFlyweight("X");
    flyweight1.operate(--i);

    Flyweight flyweight2 = factory.getFlyweight("Y");
    flyweight2.operate(--i);

    Flyweight flyweight3 = factory.getFlyweight("Z");
    flyweight3.operate(--i);
  }
コード例 #2
0
 public void Operation(String key, boolean shared) {
   Flyweight flyweight;
   if (shared) {
     flyweight = FlyweightFactory.getFlyweight(key);
   } else {
     flyweight = new UnsharedConcreteFlyweight(key);
   }
   flyweight.Operation("changed extrinsicly");
 }