Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING PYTHON PROGRAMMING LANGUAGE Create a new class called Flower. Flower is su

ID: 3767054 • Letter: U

Question

USING PYTHON PROGRAMMING LANGUAGE

Create a new class called Flower. Flower is subclassed from the plant class; so besides name, and leaves, it adds 2 new attributes; color, petals, Color is a string that contains of the flower, and petals is an int that has the number of petals on the flower. you should create an_int_method to setup the instance. with the init you should make an unbound method call to setup the name and height. in addition, create a method called pick_petal that decrements the number of petals on the flower.

Explanation / Answer

class Plant
{
public:
   char name[20];
   float height;
   void plant(char n[], float h)
   {
       strcpy(name, n);
       height=h;
   }
};
class Flower : Plant
{
public:
   char color[20];
   int petals;
   Flower(char c[], int p)
   {
       strcpy(color,c);
       petals=p;
       plant("Rose",12.5);
   }
   void pick_petal()
   {
       petals--;
   }
};