Question: Given a base Plant class and a derived Flower class, write a program to create a list called my _ garden. Store objects that belong
Given a base Plant class and a derived Flower class, write a program to create a list called mygarden. Store objects that belong to the Plant class or the Flower class in the list. Create a function called printlist that uses the printinfo instance methods defined in the respective classes and prints each element in mygarden. The program should read plants or flowers from input ending with add each Plant or Flower to the mygarden list, and output each element in mygarden using the printinfo function.
Note: A list can contain different data types and also different objects.
Ex If the input is:
plant Spirea flower Hydrangea false lilac flower Rose false white plant Mint
the output is:
Plant Information: Plant name: Spirea Cost: Plant Information: Plant name: Hydrangea Cost: Annual: false Color of flowers: lilac Plant Information: Plant name: Rose Cost: Annual: false Color of flowers: white Plant Information: Plant name: Mint Cost:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
