Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C++ Please Problem B: A Simple Color Class (20 points) In this problem, you will write a simple color class. Proper color representation is
In C++ Please
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 error message, and set all member variables to the value 0 . Member Functions: The class should have the following public member functions get_r) takes no arguments and should return the red component get_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 of the arguments is outside the range 0 to 255, then the method should print an error message and not change any of the component values 3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started