# Arup Guha
# 6/19/2017
# Stars program to practice nested loops.
# Edited in class on 6/15/2022 to add a function for a circle.

QUIT = 7

def main():

    menu()
    choice = int(input("What is your choice?\n"))

    # Continue printing until the user quits.
    while choice != QUIT:

        # All designs take in a character, so do this first.
        ch = input("What character do you want for your design?\n")

        # First choice - parallelogram
        if choice == 1:
            rows = int(input("How many rows in your parallelogram?\n"))
            cols = int(input("How many columns in your parallelogram?\n"))
            parallelogram(rows, cols, ch)

        # Second choice - right triangle, left justified
        elif choice == 2:
            n = int(input("How many rows for your left justified right triangle?\n"))
            rightTri(n, ch)

        # Third choice - right triangle, right justified
        elif choice == 3:
            n = int(input("How many rows for your right justified right triangle?\n"))
            rightJustifiedTri(n, ch)

        elif choice == 4:
            radius = int(input("What is the radius of your circle?\n"))
            circle(radius, ch)

        # Error message.
        elif choice != QUIT:
            print("Sorry, that was an invalid choice.")

        # Get next choice.
        menu()
        choice = int(input("What is your choice?\n"))

def menu():

    print("Please choose one of the following options:")
    print("1. Print a parallelogram.")
    print("2. Print a left justified right triangle.")
    print("3. Print a right justified right triangle.")
    print("4. Print a circle.")
    #print("5. Print a regular pyramid.")
    #print("6. Print a diamond.")
    print("7. Quit")
    
# Prints out a left justified triangle of n rows using character c.
def rightTri(n, c):

    # Print out row i.
    for i in range(1,n+1):

        # We need i copies of character c.
        for j in range(i):
            print(c,end="")
        print()

# Prints out a right justifed triangle of n rows using character c.
def rightJustifiedTri(n, c):

    # i is the row number.
    for i in range(1, n+1):

        # Print n-i spaces
        for j in range(n-i):
            print(" ", end="")

        # Print i copies of character c.
        for j in range(i):
            print(c, end="")

        # Go to the new line.
        print()

# Prints a parallelogram with rows # of rows, cols # of cols using
# character c.
def parallelogram(rows, cols, c):

    # Go through each row.
    for i in range(rows):

        # Print i spaces.
        for j in range(i):
            print(" ", end="")

        # Print cols copies of character c.
        for j in range(cols):
            print(c, end ="")

        # Go to the next line.
        print()

# Prints out a circle with radius r characters using character c.
def circle(r,c):

    # Go through each "pixedl"
    for y in range(-r, r+1):
        for x in range(-r, r+1):

            # If close enough to the middle, print c.
            if x*x + y*y <= r*r:
                print(c, end="")

            # Otherwise, not part of circle, print space.
            else:
                print(" ", end="")

        # Advance to the next line.
        print()
        

main()
