55"""
66
77from ..api .cat import Cat
8+ from ..utils import facts
89
910class Owner :
1011 """
11- Represents a cat owner who can care for one or more cats.
12+ Represents a cat owner who can care for one or more cats
1213
1314 Parameters
1415 ----------
@@ -48,6 +49,27 @@ class Owner:
4849 print([cat.name for cat in owner2.cats_owned])
4950
5051 """
52+
53+ def give_fact (self ):
54+ """
55+ calls ..utils.random_facts() and return a random fact about cats
56+
57+ Returns
58+ -------
59+ str
60+ A fact randomly chosen from a pre-defined fact pool
61+
62+ Examples
63+ --------
64+
65+ .. jupyter-execute::
66+
67+ import pyCatSim as cats
68+ nutmeg = cats.Cat(name='Nutmeg', age = 3, color = 'tortoiseshell')
69+ nutmeg.give_fact()
70+ """
71+ return facts .random_facts ()
72+
5173 def __init__ (self , name , cats_owned ):
5274
5375 if isinstance (cats_owned , Cat ):
@@ -60,3 +82,84 @@ def __init__(self, name, cats_owned):
6082
6183 self .name = name
6284 self .cats_owned = cats_owned
85+
86+ def adopt (self , cats_object ):
87+
88+ """
89+ Add a Cat object or a list of Cat objects to an owner's cats.
90+
91+ Parameters
92+ ----------
93+ cats_object: the cat to be added to the list
94+
95+ Raises
96+ ------
97+ TypeError
98+ If any of the arguments are not Cat.
99+ ValueError
100+ If cats_object is not Cat.
101+
102+ Examples
103+ --------
104+
105+ .. jupyter-execute::
106+
107+ import pyCatSim as cats
108+
109+ cat1 = cats.Cat(name="Whiskers")
110+ cat2 = cats.Cat(name="Boots", color="tabby")
111+ owner1 = Owner(name="Sasha", cats_owned=cat1)
112+ owner2 = Owner(name="Liam", cats_owned=[cat1, cat2])
113+
114+ chestnut = cats.Cat(name='Chestnut', age = 4, color = 'tabby')
115+ nutmeg = cats.Cat(name='Nutmeg', age = 3, color = 'tortoiseshell')
116+ owner1.adopt(owner1,nutmeg)
117+ owner2.adopt(owner2,[chestnug,nutmeg])
118+
119+ print(owner1.name)
120+ print([cat.name for cat in owner2.cats_owned])
121+
122+
123+ """
124+ if isinstance (cats_object , Cat ):
125+ self .cats_owned .append (cats_object )
126+ elif isinstance (cats_object , list ):
127+ if not all (isinstance (cat , Cat ) for cat in cats_object ):
128+ raise TypeError ("All elements in cats_object must be instances of Cat." )
129+ else :
130+ self .cats_owned += cats_object
131+ else :
132+ raise TypeError ("cats_owned must be a Cat instance or a list of Cat instances." )
133+
134+
135+ def groom (self ,Cat ):
136+ """
137+ Simulates an owner grooming one cat, increasing its mood by one
138+
139+ Parameters
140+ ----------
141+ Cat : pyCatSim.Cat
142+ a pyCatSim.Cat object that you would like to groom.
143+
144+ Returns
145+ -------
146+ None.
147+
148+
149+ Examples
150+ --------
151+ .. jupyter-execute::
152+
153+ from pyCatSim import Cat, Owner
154+
155+ cat1 = Cat(name="Whiskers")
156+
157+ Deborah = Owner(name="Deborah", cats_owned=cat1)
158+
159+ Deborah.groom(cat1)
160+
161+ """
162+
163+ Cat .mood += 1
164+
165+
0 commit comments