/*
 * TwoTrianglesStructured.java
 * Computer Science S-111
 * 
 * This is an structured version of a program that prints
 * two triangular-shaped figures composed of copies of
 * a single character. It's structured because it uses
 * a separate method that prints a triangle, rather than
 * doing everything in the main method.
 * 
 * See TwoTriangles.java for the original, unstructured version.
 */

public class TwoTrianglesStructured {
    /*
     * printTriangle - prints a triangle composed of copies 
     * of the character specified by the parameter ch.
     * The triangle has one character in the first row,
     * two characters in the second row, etc., and the
     * number of characters in the bottom row is given by
     * the parameter base.
     */
    public static void printTriangle(int base, char ch) {
        for (int line = 1; line <= base; line++) {
            for (int i = 0; i < line; i++) {
                System.out.print(ch);
            }
            System.out.println();
        }
    }
        
    public static void main(String[] args) {
        char ch = '*';      // character used in printing
        int smallBase = 5;  // base length of smaller triangle
        
        // Print the small triangle.
        printTriangle(smallBase, ch);
        
        // Print the large triangle.
        printTriangle(2 * smallBase, ch);
    }
}