Tuesday, August 20, 2019

OOP oldest dog

class Dog:
    species = 'mammal'
    def __init__(self, name, age):
        self.name = name
        self.age = age

goofy = Dog("Goofy", 7)
brian = Dog("Brian", 9)
pluto = Dog("Pluto", 4)


# Determine the oldest dog
def get_biggest_number(*args):
    return max(args)

def get_oldest_dog():
    if (goofy.age > brian.age) and (goofy.age > pluto.age) :
        return "Goofy"
    elif (pluto.age > brian.age) and (pluto.age > goofy.age) :
        return "Pluto"
    else :
        return "Brian"
 

# Output
print("The oldest dog is {} years old.".format(
    get_biggest_number(goofy.age, brian.age, pluto.age)))

print ("{} is the oldest freak !!!". format(get_oldest_dog()))



No comments:

Post a Comment