For this problem, you will design and implement 2 classes and then write a drive
ID: 3658236 • Letter: F
Question
For this problem, you will design and implement 2 classes and then write a driver function to test these classes. The first will be a C++ class for an abstract data type color with a public enumeration type colorType that has the color values shown in Listing 10.8. Your abstract data type should have an attribute for storing a single value of type colortype and member functions for reading (readColor) and writing (writeColor) a color value as well as setting and accessing it. The function readColor should read a color as a string and store the corresponding color value in the value attribute of a type color object. The function writeColor should display as a string the value stored in the value attribute of a type color object (see Figure 7.5). Modify class circle and the driver function in Listing 10.9 to include and use this class. You
Explanation / Answer
//color.h //Color class definition #ifndef COLOR_H #define COLOR_H class color { public: enum colorType {black, blue, green, cyan, red, magenta, brown, lightgray, nocolor}; //Member functions //read color in void readColor (color); //write color out void writeColor (color); //accessor functions color getColor() const; private: //data members color cColor; }; #endif // File color.cpp // Color class implementation #include "color.h" #include using namespace std; // Member Functions... // Set color void color::readColor(color c) { cColor = c; } void color::writeColor() const { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.