AnimalShelter.py The Animal Shelter.py file will contain the definition of what a single AnimalShelter object is. The string should contain all attributes in the following EXACT format: a = Animal("dog", 12.2, 2, "Ruffles") print(a.toString()) Output: Species: DOG, Name: RUFFLES, Age: 2, Weight: 12.2 Note: The a.toString() return value in the example above does not contain a newline character (\n) at the end. setAge(self, age) Įach Animal object should be able to call a method toString that returns a str with all the animal attributes. _init_(self, species, weight, age, name) In addition to your constructor, your class definition should also support "setter" methods that can update the state of the Animal objects:.Your constructor should set these attributes with the value None by default. You should write a constructor that allows the user to construct an animal object by passing in values for all of the fields. Your program should ensure this field will be stored in all upper-case characters. name - str that represents the name of the animal.age - int that represents the age (in years) of an animal.weight - float that represents the weight (in lbs) of an animal.Your program should ensure that this field will be stored in all upper-case characters. species - str that represents the species of the animal.We will define the Animal attributes as follows: Animal.py class The Animal.py file will contain the definition of what an Animal is. Also, this will be easy to import various files into your code using the import / from technique shown in lecture. ![]() This way all files for a lab are located in a single folder. It's recommended that you organize your lab work in its own directory. ![]() There will be no starter code for this assignment, but rather the class descriptions and required methods are defined in the specification below. testFile.py - file containing pytest functions testing both Animal Shelter and Animal objects.AnimalShelter.py - file containing a class definition for an Animal Shelter object.Animal.py - file containing a class definition for an Animal object.Instructions You will need to create three files:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |