예제 #1
0
  /**
   * printBrick Prints a String representation of a Brick with its subblocks to the error
   * printstream
   */
  public void printBrick() {
    String brickName = this.getName();
    if (!this.getVariant().isEmpty()) {
      brickName += "(" + this.getVariant() + ")";
    }
    String brickKey = BrickLibrary.keyNumToName(this.getKey());
    long brickDur = this.getDuration();
    String brickType = this.getType();
    System.out.println(
        "Printing brick " + brickName + " " + brickType + " " + brickKey + " " + brickDur);

    ArrayList<Block> subBlockList = this.getSubBlocks();
    Iterator<Block> blockIter = subBlockList.iterator();

    while (blockIter.hasNext()) {
      Block currentBlock = blockIter.next();

      if (currentBlock instanceof Brick) {
        Brick currentBrick = (Brick) currentBlock;
        String currentBrickName = currentBrick.getName();
        Long currentBrickKey = currentBrick.getKey();
        String currentBrickKeyString = BrickLibrary.keyNumToName(currentBrickKey);
        long dur = currentBrick.getDuration();
        System.out.println(
            "Printing brick " + currentBrickName + " " + currentBrickKeyString + " " + dur);
      } else if (currentBlock instanceof ChordBlock) {
        ChordBlock currentChord = (ChordBlock) currentBlock;
        String currentChordName = currentChord.getName();
        int currentDuration = currentChord.getDuration();
        System.out.println("Printing Chord" + currentChordName + " " + currentDuration);
      }
    }
  }