Mei’s Plant class can now look after its own data. The day count is private, .needsWater is worked out each time it’s read, and the class rejects negative intervals. So far, though, you’ve built each of those pieces in a lesson or exercise of its own.
In this project, you’ll put them together into the care tracker Mei has wanted since her plants were plain records. You’ll build a Plant class from a short description, then a Shelf that holds her plants and tells her which ones need water today. This page is the brief, and you’ll come back to it while you build. Start with what Mei wants the tracker to do for her.
What Mei Wants
Mei keeps four houseplants on the shelf by her window, and each one needs water on its own schedule. These are the plants you’ve followed through the course, with the data Mei started with:
- Goldie, the pothos: water every 5 days, last watered 6 days ago.
- Moss, the monstera: water every 7 days, last watered 3 days ago.
- Lily, the peace lily: water every 4 days, last watered 4 days ago.
- Spike, the cactus: water every 21 days, last watered 10 days ago.
Each morning, Mei wants to ask the shelf which plants need water, water them, and be sure none were missed. Before a weekend away, she keeps it simpler and waters every plant, due or not, so none dries out while she’s gone.
She also wants the data to stay sensible. A stray line of code shouldn’t be able to change a plant’s day count, and no plant should ever get a negative watering interval. Her partner, Ravi, has a few plants of his own, so whatever works for Mei’s shelf should work for a second shelf too.