Write a class to represent an object with different states such as a switch (on/off), light bulb (on/off or (off/green/red)) or emoticon (happy/sad). Screen location should be a property of the object. Provide a function draw(Graphics g) to draw the object on the screen. Write a main program to instantiate and display several objects, each with a different state. Solution This program is used to represent a class for a bulb. Three objects are used to represent different states(off/red/green) of the bulb. #include<iostream.h> #include<graphics.h> enum bstate {off=15,green=2,red=4}; //class for a light bulb class bulb { int state; int x,y; public: bulb(int,int,int); void draw(); }; //Constructor to initialize bulb object bulb::bulb(int a,int b,int s) { state=s; x=a; y=b; } //function to draw the bulb in their respective screen coordinates and color void bulb::draw() { setcolor(state); setfillstyle(SOLID_FILL,state); fillellipse(x,y,15,15); } int main() { int gdriver = DETECT, gmode; initgraph(&gdriver, &gmode, \"..\\\\bgi\"); bulb offbulb(50,50,off); //initialize off bulb bulb greenbulb(50,150,green); Â Â //initialize green bulb bulb redbulb(50,250,red); //initialize red bulb offbulb.draw(); Â Â //draw off bulb greenbulb.draw(); //draw green bulb redbulb.draw(); //draw red bulb return 0; } .