Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
78 lines (52 loc) · 1.87 KB
/
Copy pathmain.py
File metadata and controls
78 lines (52 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
Simple Python program demonstrating classes, inheritance, and various Python concepts.
This program models a Person and a Dog with their interactions.
"""
import random
# Import from config package (global variables)
from config import GREETING_MESSAGES
# Import from models package (classes with inheritance)
from models import Animal, Dog, Person
# Import from utils package (functions)
from utils import calculate_dog_years, generate_pet_name, display_separator
def main():
"""Main function to demonstrate the program."""
print("Welcome to the Person and Dog Program!")
display_separator()
# Create a person
person = Person("Alice", 28)
print(person.greet())
print(f"Age: {person.age}")
display_separator()
# Create dogs
dog1 = Dog("Buddy", 3, "Golden Retriever")
dog2 = Dog("Max", 5, "German Shepherd")
print(f"Created dog: {dog1.get_info()}")
print(f"Dog years: {calculate_dog_years(dog1.age)}")
print(f"Sound: {dog1.make_sound()}")
display_separator()
# Teach the dog tricks
dog1.learn_trick("sit")
dog1.learn_trick("roll over")
dog1.learn_trick("fetch")
display_separator()
# Person adopts pets
person.adopt_pet(dog1)
person.adopt_pet(dog2)
display_separator()
# List all pets
person.list_pets()
display_separator()
# Play with pets
person.play_with_pet("Buddy")
display_separator()
# Demonstrate global variable usage
print(f"Random greeting from global list: {random.choice(GREETING_MESSAGES)}")
display_separator()
# Demonstrate the generate_pet_name utility function
random_name = generate_pet_name()
print(f"Generated random pet name: {random_name}")
display_separator()
print("Program completed successfully!")
if __name__ == "__main__":
main()