@@ -93,12 +93,14 @@ def __init__(self, name, age=None, color=None, mood=0, hunger_level=0,
9393
9494 def give_fact (self ):
9595 """
96- calls ..utils.random_facts() and return a random fact about cats
96+ Gives a random fact about cats
9797
9898 Returns
9999 -------
100100 str
101101 A fact randomly chosen from a pre-defined fact pool
102+
103+ Examples
102104 --------
103105
104106 .. jupyter-execute::
@@ -111,7 +113,7 @@ def give_fact(self):
111113
112114 def make_noise (self , noise = 'meow' , play = False ):
113115 """
114-
116+ Have the cat make a noise
115117
116118 Parameters
117119 ----------
@@ -177,52 +179,52 @@ def make_noise(self, noise='meow', play=False):
177179
178180 def play (self , mood_boost = 1 , hunger_boost = 1 , energy_boost = - 1 ):
179181
180- """
181- Simulates playtime with the cat.
182-
183- Parameters
184- ----------
185- mood_boost : int, optional
186- How much mood improves from play. Must be an integer. Default is 1.
187- hunger_boost : int, optional
188- How much hunger increases from play. Must be a positive integer. Default is 1.
189- energy_boost : int, optional
190- How much energy decreases from play. Must be a negative integer. Default is -1.
182+ """
183+ Simulates playtime with the cat.
184+
185+ Parameters
186+ ----------
187+ mood_boost : int, optional
188+ How much mood improves from play. Must be an integer. Default is 1.
189+ hunger_boost : int, optional
190+ How much hunger increases from play. Must be a positive integer. Default is 1.
191+ energy_boost : int, optional
192+ How much energy decreases from play. Must be a negative integer. Default is -1.
193+
194+ Raises
195+ ------
196+ TypeError
197+ If any of the arguments are not integers.
198+ ValueError
199+ If hunger_boost is not positive or energy_boost is not negative.
200+
201+ Examples
202+ --------
191203
192- Raises
193- ------
194- TypeError
195- If any of the arguments are not integers.
196- ValueError
197- If hunger_boost is not positive or energy_boost is not negative.
198-
199- Examples
200- --------
204+ .. jupyter-execute::
201205
202- .. jupyter-execute::
203-
204- import pyCatSim as cats
205- nutmeg = cats.Cat(name='Nutmeg', age = 3, color = 'tortoiseshell')
206- nutmeg.play()
207-
206+ import pyCatSim as cats
207+ nutmeg = cats.Cat(name='Nutmeg', age = 3, color = 'tortoiseshell')
208+ nutmeg.play()
208209
209- """
210- for arg_name , arg_value in {
211- "mood_boost" : mood_boost ,
212- "hunger_boost" : hunger_boost ,
213- "energy_boost" : energy_boost
214- }.items ():
215- if not isinstance (arg_value , int ):
216- raise TypeError (f"{ arg_name } must be an integer." )
217210
218- if hunger_boost <= 0 :
219- raise ValueError ("Cats always get hungry when playing! hunger_boost must be positive." )
220- if energy_boost >= 0 :
221- raise ValueError ("Cats always get tired when playing! energy_boost must be negative." )
222-
223- self .mood += mood_boost
224- self .hunger_level += hunger_boost
225- self .energy += energy_boost
211+ """
212+ for arg_name , arg_value in {
213+ "mood_boost" : mood_boost ,
214+ "hunger_boost" : hunger_boost ,
215+ "energy_boost" : energy_boost
216+ }.items ():
217+ if not isinstance (arg_value , int ):
218+ raise TypeError (f"{ arg_name } must be an integer." )
219+
220+ if hunger_boost <= 0 :
221+ raise ValueError ("Cats always get hungry when playing! hunger_boost must be positive." )
222+ if energy_boost >= 0 :
223+ raise ValueError ("Cats always get tired when playing! energy_boost must be negative." )
224+
225+ self .mood += mood_boost
226+ self .hunger_level += hunger_boost
227+ self .energy += energy_boost
226228
227229 def bathe (self ):
228230 """
@@ -376,75 +378,3 @@ def sleep(self, duration=0):
376378 energy_boost = math .floor (duration / 3 )
377379
378380 self .energy += energy_boost
379-
380- class Clowder :
381- """
382- Represents a group of cats.
383-
384- Parameters
385- ----------
386- catlist: list
387- A list of cats from the Cat class
388-
389- Attributes
390- ----------
391- catlist: list
392- A list of cats from the Cat class
393-
394- Examples
395- --------
396-
397- .. jupyter-execute::
398-
399- import pyCatSim as cats
400- group = cats.Clowder(catlist = [list_of_Cats])
401- """
402-
403- def __init__ (self , catlist = None ):
404- if catlist is None :
405- catlist = []
406- elif not all (isinstance (cat ,Cat ) for cat in catlist ):
407- raise TypeError ("All elements of the list must be a Cat object" )
408- self .catlist = catlist
409-
410-
411- def add_cat (self , cat ):
412-
413- """
414- Adds a Cat to the Clowder
415-
416- Parameters:
417- -----------
418- cat: Cat
419- the new Cat to add
420-
421- Raises
422- ------
423- TypeError
424- If any of the arguments are not Cat instances.
425- """
426-
427- if not isinstance (cat , Cat ):
428- raise TypeError ("Only Cat objects can be added." )
429- self .catlist .append (cat )
430-
431-
432- def remove_cat (self ,cat ):
433- """
434- Removes a Cat from the Clowder
435-
436- Parameters:
437- -----------
438- cat: Cat
439- the Cat to remove
440-
441- Raises
442- ------
443- ValueError
444- If the Cat is not found in the clowder.
445- """
446-
447- try :
448- self .catlist .remove (cat )
449- except ValueError :
450- raise ValueError ("Cat not found in Clowder" )
0 commit comments