Package specifications

Examples of specifications.BranchOfTreeSpecification


public class TestStarDecorator {

  public static void main(String[] args) {

    BranchOfTreeSpecification plainBranch = new UndecoratedBranch();
    BranchOfTreeSpecification decoratedBranch = new StarDecorator(
        plainBranch);
    BranchOfTreeSpecification reDecoratedBranch = new StarDecorator(
        new StarDecorator(plainBranch));

    System.out.println("plainBranch.getDecorations() ="
        + plainBranch.getDecorations());
    System.out.println("decoratedBranch.getDecorations() ="
        + decoratedBranch.getDecorations());
    System.out.println("reDecoratedBranch.getDecorations() ="
        + reDecoratedBranch.getDecorations());

    plainBranch.animate();
    System.out.println("plainBranch.animate.getDecorations() ="
        + plainBranch.getDecorations());

    decoratedBranch.animate();
    System.out.println("decoratedBranch.animate.getDecorations() ="
        + decoratedBranch.getDecorations());

    reDecoratedBranch.animate();
    System.out.println("reDecoratedBranch.animate.getDecorations() ="
        + reDecoratedBranch.getDecorations());
  }
View Full Code Here


public class TestBallLightDecorator {

  public static void main(String[] args) {

    BranchOfTreeSpecification plainBranch = new UndecoratedBranch();
    BranchOfTreeSpecification decoratedBranchLightBall = new LightsDecorator(
        new BallDecorator(plainBranch));

    BranchOfTreeSpecification reDecoratedBallLight = new BallDecorator(
        new LightsDecorator(plainBranch));

    System.out.println("plainBranch.getDecorations() ="
        + plainBranch.getDecorations());
    System.out.println("decoratedBranchLightBall.getDecorations() ="
        + decoratedBranchLightBall.getDecorations());
    System.out.println("reDecoratedBallLight.getDecorations() ="
        + reDecoratedBallLight.getDecorations());

    // Animate the first time
    System.out.println();
    plainBranch.animate();
    System.out.println("plainBranch.animate.getDecorations() ="
        + plainBranch.getDecorations());

    decoratedBranchLightBall.animate();
    System.out
        .println("decoratedBranchLightBall.animate.getDecorations() ="
            + decoratedBranchLightBall.getDecorations());
    reDecoratedBallLight.animate();

    System.out.println("reDecoratedBallLight.animate.getDecorations() ="
        + reDecoratedBallLight.getDecorations());

    // Animate the second time
    System.out.println();
    plainBranch.animate();
    System.out.println("plainBranch.animate.getDecorations() ="
        + plainBranch.getDecorations());

    decoratedBranchLightBall.animate();
    System.out
        .println("decoratedBranchLightBall.animate.getDecorations() ="
            + decoratedBranchLightBall.getDecorations());

    reDecoratedBallLight.animate();
    System.out.println("reDecoratedBallLight.animate.getDecorations() ="
        + reDecoratedBallLight.getDecorations());
  }
View Full Code Here

public class TestAllDecorators {

  public static void main(String[] args) {

    BranchOfTreeSpecification plainBranch = new UndecoratedBranch();
    BranchOfTreeSpecification decoratedBranchWithStar = new StarDecorator(
        plainBranch);

    BranchOfTreeSpecification redecoratedBranchWithStarBall = new BallDecorator(
        decoratedBranchWithStar);

    BranchOfTreeSpecification redecoratedBranchWithStarBallLight = new LightsDecorator(
        redecoratedBranchWithStarBall);
    BranchOfTreeSpecification redecoratedBranchWithStarBall2Light = new BallDecorator(
        redecoratedBranchWithStarBallLight);
    BranchOfTreeSpecification redecoratedBranchWithStarBall3Light = new StarDecorator(
        redecoratedBranchWithStarBall2Light);
    BranchOfTreeSpecification redecoratedBranchWithStarBall4Light = new LightsDecorator(
        redecoratedBranchWithStarBall3Light);
    BranchOfTreeSpecification redecoratedBranchWithStarBall5Light = new BallDecorator(
        redecoratedBranchWithStarBall4Light);

    System.out.println("At beginning: "
        + redecoratedBranchWithStarBall5Light.getDecorations());

    // Animate the first time
    redecoratedBranchWithStarBall5Light.animate();
    System.out.println("\nanimate 1: "
        + redecoratedBranchWithStarBall5Light.getDecorations());

    // Animate the second time
    redecoratedBranchWithStarBall5Light.animate();
    System.out.println("\nanimate 2: "
        + redecoratedBranchWithStarBall5Light.getDecorations());

    // Animate the second time
    redecoratedBranchWithStarBall5Light.animate();
    System.out.println("\nanimate 3: "
        + redecoratedBranchWithStarBall5Light.getDecorations());

    // Animate the second time
    redecoratedBranchWithStarBall5Light.animate();
    System.out.println("\nanimate 4: "
        + redecoratedBranchWithStarBall5Light.getDecorations());

  }
View Full Code Here

  /**
   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    BranchOfTreeSpecification plainBranch = new UndecoratedBranch();
    BranchOfTreeSpecification lightBranch = new LightsDecorator(plainBranch);
    BranchOfTreeSpecification ballBranch = new BallDecorator(plainBranch);
    BranchOfTreeSpecification starBranch = new StarDecorator(plainBranch);

    XMASTree myTree2Light2Ball = new XMASTree(4);
    myTree2Light2Ball.addDecorator(lightBranch);
    myTree2Light2Ball.animate();
    myTree2Light2Ball.addDecorator(lightBranch);
View Full Code Here

public class TestBallDecorator {
 
  public static void main (String [] args){
 
  BranchOfTreeSpecification plainBranch = new UndecoratedBranch();
  BranchOfTreeSpecification decoratedBranch = new BallDecorator( plainBranch);
  BranchOfTreeSpecification reDecoratedBranch = new BallDecorator( new BallDecorator( plainBranch));
 
  System.out.println("plainBranch.getDecorations() ="+plainBranch.getDecorations());
  System.out.println("decoratedBranch.getDecorations() ="+decoratedBranch.getDecorations());
  System.out.println("reDecoratedBranch.getDecorations() ="
                  +reDecoratedBranch.getDecorations());
 
  plainBranch.animate();
  System.out.println("plainBranch.animate.getDecorations() ="+plainBranch.getDecorations());
 
  decoratedBranch.animate();
  System.out.println("decoratedBranch.animate.getDecorations() ="+decoratedBranch.getDecorations());
 
  reDecoratedBranch.animate();
  System.out.println("reDecoratedBranch.animate.getDecorations() ="
                  +reDecoratedBranch.getDecorations());
  }
View Full Code Here

    if (decorateBranch instanceof UndecoratedBranch) {
      System.out.println("The add decorator doesn't have any decorator!");
    } else {
      boolean replaceOK = false;
      while (!replaceOK) {
        BranchOfTreeSpecification randomBranch = getRandomBranch();
        if (randomBranch.getDecorations().contains(
            decorateBranch.getDecorations())) {
          BranchOfTreeSpecification newBranch = decorate(
              randomBranch, decorateBranch);
          listBranchs.remove(randomBranch);
          listBranchs.add(newBranch);
          replaceOK = true;
        } else {
          randomBranch.animate();
          if (randomBranch.getDecorations().contains(
              decorateBranch.getDecorations())) {
            BranchOfTreeSpecification newBranch = decorate(
                randomBranch, decorateBranch);
            listBranchs.remove(randomBranch);
            newBranch.animate();
            listBranchs.add(newBranch);
            replaceOK = true;
          }
        }
      }
View Full Code Here

public class TestMultiDecorators {

  public static void main(String[] args) {

    BranchOfTreeSpecification plainBranch = new UndecoratedBranch();
    BranchOfTreeSpecification decoratedBranchWithStar = new StarDecorator(
        plainBranch);

    BranchOfTreeSpecification redecoratedBranchWithStarBall = new BallDecorator(
        decoratedBranchWithStar);

    BranchOfTreeSpecification redecoratedBranchWithStarBallLight = new LightsDecorator(
        redecoratedBranchWithStarBall);

    System.out.println("\nplainBranch.getDecorations() ="
        + plainBranch.getDecorations());
    System.out.println("decoratedBranchWithStar.getDecorations() ="
        + decoratedBranchWithStar.getDecorations());
    System.out.println("redecoratedBranchWithStarBall.getDecorations() ="
        + redecoratedBranchWithStarBall.getDecorations());

    System.out
        .println("redecoratedBranchWithStarBallLight.getDecorations() ="
            + redecoratedBranchWithStarBallLight.getDecorations());

    // Animate the first time
    plainBranch.animate();
    System.out.println("\nplainBranch.animate.getDecorations() ="
        + plainBranch.getDecorations());

    decoratedBranchWithStar.animate();
    System.out.println("decoratedBranchWithStar.animate.getDecorations() ="
        + decoratedBranchWithStar.getDecorations());

    redecoratedBranchWithStarBall.animate();
    System.out
        .println("redecoratedBranchWithStarBall.animate.getDecorations() ="
            + redecoratedBranchWithStarBall.getDecorations());

    redecoratedBranchWithStarBallLight.animate();
    System.out
        .println("redecoratedBranchWithStarBallLight.animate.getDecorations() ="
            + redecoratedBranchWithStarBallLight.getDecorations());

    // Animate the second time
    plainBranch.animate();
    System.out.println("\nplainBranch.animate.getDecorations() ="
        + plainBranch.getDecorations());

    decoratedBranchWithStar.animate();
    System.out.println("decoratedBranchWithStar.animate.getDecorations() ="
        + decoratedBranchWithStar.getDecorations());

    redecoratedBranchWithStarBall.animate();
    System.out
        .println("redecoratedBranchWithStarBall.animate.getDecorations() ="
            + redecoratedBranchWithStarBall.getDecorations());

    redecoratedBranchWithStarBallLight.animate();
    System.out
        .println("redecoratedBranchWithStarBallLight.animate.getDecorations() ="
            + redecoratedBranchWithStarBallLight.getDecorations());
  }
View Full Code Here

public class TestLightDecorator {

  public static void main(String[] args) {

    BranchOfTreeSpecification plainBranch = new UndecoratedBranch();
    BranchOfTreeSpecification decoratedBranch = new LightsDecorator(
        plainBranch);
    BranchOfTreeSpecification reDecoratedBranch = new LightsDecorator(
        new LightsDecorator(plainBranch));

    System.out.println("plainBranch.getDecorations() ="
        + plainBranch.getDecorations());
    System.out.println("decoratedBranch.getDecorations() ="
        + decoratedBranch.getDecorations());
    System.out.println("reDecoratedBranch.getDecorations() ="
        + reDecoratedBranch.getDecorations());

    plainBranch.animate();
    System.out.println("plainBranch.animate.getDecorations() ="
        + plainBranch.getDecorations());

    decoratedBranch.animate();
    System.out.println("decoratedBranch.animate.getDecorations() ="
        + decoratedBranch.getDecorations());

    reDecoratedBranch.animate();
    System.out.println("reDecoratedBranch.animate.getDecorations() ="
        + reDecoratedBranch.getDecorations());

    plainBranch.animate();
    System.out.println("plainBranch.animate.getDecorations() ="
        + plainBranch.getDecorations());

    decoratedBranch.animate();
    System.out.println("decoratedBranch.animate.getDecorations() ="
        + decoratedBranch.getDecorations());

    reDecoratedBranch.animate();
    System.out.println("reDecoratedBranch.animate.getDecorations() ="
        + reDecoratedBranch.getDecorations());
  }
View Full Code Here

TOP

Related Classes of specifications.BranchOfTreeSpecification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.