I am having a few issues with this program, they stem from passing the color.h and .cpp into another .h and .cpp, and frankly getting how those two things really fit together.
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’ll need to remove the declaration for color in class circle. Test your modified driver function with the new color and circle classes.
The second class will be to design and implement a rectangle class similar to class circle. Be sure to incorporate the new color class you have written and tested in the first part of the programming exercise. Write a client program that asks the user to enter a shape name (circle or rectangle) and then asks the user for the necessary data for an object of that class. The program should create the object and display all its attributes.
The circle class .h and .cpp files as well as the original driver function will be supplied. You are to provide the .h and .cpp files for the new color class and the modified driver function as well as the .h and .cpp files for the rectangle class and the client program that uses all three classes.
//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 circle.h
// Circle class definition
#include "color.h"
#ifndef CIRCLE_H
#define CIRCLE_H
class circle
{
public:
// Member Functions
// constructor
circle(int);
// Set center coordinates
void setCoord(int, int);
// Set radius
void setRadius(int);
// Set color
void readColor(color);
// Compute the area
float computeArea();
// Compute the perimeter
float computePerimeter();
// Display attributes
void displayCircle() const;
// accessor functions
int getX() const;
int getY() const;
int getRadius() const;
color getColor() const;
private:
// Data members (attributes)
int x;
int y;
int radius;
color cColor;
};
#endif // CIRCLE_H