Assignment 1
Using classes
Submit before 11:30 Saturday April 11
Overview
For this assignment, you will continue your practice of using and modifying the Plant class.
Note: your code must work with the Plant class provided for
this assignment. You will not receive any credit if your code works
with a different version of this class.
Code writing and questions
- Complete syllabus quiz. Note your experience and completion of it in your assignment report.
- Use the Plant class from the class or download the zip folder for the plant class.
- Review the code in files plant.py and demo.py from the lab. Run the demo functions in demo.py and familiarize yourself with what they do and how they work.
- What are the instance variables for the Plant class? In the interactive shell, create a Plant object, call several methods, and then use the dot-notation to reveal the current state of the instance variables.
- Write a function called plant_races that takes a list of strings as an argument. Each string respresents a single plant name. The function should then do the following:
- For each plant name, create a Plant object with that name and append it to a list (call it garden).
- For each plant object in the garden list, grow it for 20 days, watering it each day.
- Loop through the garden of plants to determine the plant with the largest size and print out its name.
- Modify the Plant class with the following:
- New instance variable called nutrient_level
- New method called fertilize, which takes a positive integer as an argument and adds it to the nutrient_level
- When the plant grows in tick_day, add the nutrient_level to its size
- Test your modifications to show that they work
- Modify the Plant class so that it has an instance variable called alive that is initially set to True. Modify the methods so that the plant dies under your own specifications (e.g. water_level over 4) and so that the plant doesn't increase in size if it is not alive. Show that it works.
Deliverable
Create a text, word or pdf file that contains the following:
- A statement that summarizes your completion of the assignment. The
statement should include any help you received or whether you
discussed your assignment with others. Keep in mind that you may
not copy code from others (or online resources) or allow others to
copy your code.
- Your clearly labeled answers to explanations and questions
- A summary of the files included in the zip folder
- Demonstrations that show that your code works
Put your doc file and your py files in a folder, zip it, and submit it under assn1 on D2L. Check that your submitted zip file is complete.
Grading
The assignment is worth 5 points. Full credit will be awarded to complete, accurate
and well presented submissions. Points will be deducted for the following:
- Missing requirements
- Inaccuracies (possibly excepting minor ones)
- Poorly written explanations