# Author:  James Tam
# Version: May 24, 2022 (solution program)
# Learning: how functions communicated.
# *Information local to one function is needed by another function
#  e.g. prompt user for color in askColor but this function needs
#  information from another function (car)
# Note: this program is kept as simple as possible to illustrate the above
# principles consequently rather implementing a real function that performs
# one clear task but has one piece of information of information stored as
# a local and another passed as a parameter the functions were implemented
# as toy functions (Don't do anything useful) to keep them simple so they
# appear to violate the design rule (functions implement just one task).


def askCarShowColor(favoriteColor):
    print("Favorite color %s" %(favoriteColor))
    favoriteCar = input("Favorite car: ")
    return(favoriteCar)

def askColorShowCar(favoriteCar):
    print("Favorite car %s" %(favoriteCar))
    favoriteColor = input("Favorite color: ") 
    return(favoriteColor)

def start():
    stillPlaying = True
    favoriteColor = "Blue"
    favoriteCar = "Talon"
    while (stillPlaying == True):
        print("Playing")
        if (stillPlaying == True):
            favoriteCar = askCarShowColor(favoriteColor)
        if (stillPlaying == True):          
            favoriteColor = askColorShowCar(favoriteCar)
        input("Hit enter to run another turn")
        if ((favoriteCar in ("q","q") or (favoriteColor in ("q","Q")))):
            stillPlaying = False
    print("Done game")

start()
