Question: c++ program Problem B: A Simple Color Class (20 points) In this problem, you will write a simple color class. Proper color representation is necessary
c++ program



Problem B: A Simple Color Class (20 points) In this problem, you will write a simple color class. Proper color representation is necessary in a variety of applications ranging from the design, analysis, and manufacturing of automobiles and aircraft, to representing and understanding the function of biological systems, to the analysis and understanding of climate data Member Variables: The class should have three private member variables, r, that contain the red, green, and blue components of the color. g, b Constructors: The class should have the following two constructors .The default constructor should initialize all the components to 0 A constructor that takes three int arguments representing the red, green, and blue components, respectively. This should check that all three components have values that are between 0 and 255, inclusive. If they are, then the constructor should assign the argument values to the corresponding member variables. If one or more is not, then the constructor should print out an crror message, and set all member variables to the value O Member Functions: The class should have the following public member functions: get-r ( ) takes no arguments and should return the red component. qet_g ( ) takes no arguments and should return the green component. get-b ( ) takes no arguments and should return the blue component. set (int r, int g, int b) sets the value of the components to the corresponding arguments. However, if any ofthe arguments is outside the range 0 to 255, then the method should print an error message and not change any of the component values 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
