Next, make a main() function:
def main():
salut = Felicitations()
hol_type = caps(hol)
lang_choice = caps(lang)
addressee = caps(addr)
if lang_choice == "French":
language = 1
elif lang_choice == "German":
language = 2
else:
language = 0
greeting = holiday(hol_type, language)
day = greeting[0]
salutation = greeting[1]
saludos = salutation + " " + day
salut.addon(saludos)
salut.addon(", ")
salut.addon(addressee)
salut.addon(punctuation)
prints(salut)
Several things happen in this function:
- We create an instance of the 'Felicitations' class and call it 'salut'. This allows us to access the parts of 'Felicitations' as they exist in 'salut'.
- Next, we capitalise the holiday, language and addressee variables using the function caps().
- Depending on the language choice, we assign a number to language which corresponds to the item in the dictionary (associative array) of function holiday().
- Function holiday() is then called with hol_type and language as arguments. The tuple that is returned will be assigned to variable greeting.
- The values of the tuple are then assigned to day and salutation respectively.
- These are then concatenated with "+", including a space between them. The next line appends them to object salut.
- In rapid succession, the folowing are appended to object salut by the following three lines: a comma (to offset the vocative address), the addressee, and the punctuation.
- Finally, the object 'salut' is sent to function prints to be printed to the screen.
