import java.util.Scanner;

class Squares {
  public static void main(String args[]) {
    System.out.println();
    filledSquare();
    System.out.println();
  }
  public static void filledSquare() {
    Scanner scanner = new Scanner(System.in);

    System.out.print("Enter the number of rows/cols: ");
    int number = scanner.nextInt();

    System.out.println();
    filledSquare(number);
  }
  public static void filledSquare(int number) {
    filledSquare(number, 0);
  }
  public static void filledSquare(int number, int rows) {
    if (rows < number) {
      fillingARow(number, 0);
      filledSquare(number, rows + 1);
    }
  }
  public static void fillingARow(int number, int cols) {
    if (cols == number) {
      System.out.println();
    }
    else if (cols < number) {
      System.out.print("*");
      fillingARow(number, cols + 1);
    }
  }
}

/*
Handling printing on a single row

1. Base Case -> finished printing all collumns on a single row
                cols == number
2. Recursive Case -> when i still need to print more columns on this row
                     cols < number
3. Recursive Step -> traverse to the next column, printing appropriately
                     fillingARows(number, cols + 1)

Handling printing all columns data on all rows

1. Base Case -> finished printing all rows all column data
                rows == number
2. Recursive Case -> when i still need to print more rows
                     rows < number
3. Recursive Step -> fill a single row
                     move to the next row
                     fillingARow(number, 0)
                     filledSquare(number, row + 1)
*/
