Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

in C++ please Figure 1.6 in the book shows a class called IntCell. It can be considered as a wrapper around a single integer data

in C++ please

Figure 1.6 in the book shows a class called IntCell. It can be considered as a wrapper around a single integer data member storedValue. Rename this class as Color. Use 3 private integer data members: red, blue and green. Using the code in Figure 1.6 as an example, for the Color class write:

1) A default constructor

2) A constructor that takes a single integer and uses it to set red

3) A constructor that takes two integers and uses it to set red and green

4) A constructor that takes 3 integers and uses it to set red, green and blue

5) Member functions that return individual colors (get_red etc)

6) A member function that returns all three colors in a vector of integers

7) Member functions to set individual colors (set_red etc)

8) A member function to print all colors

The allowed range for all colors are from 0 to 255 (both inclusive). In all functions that set one or more colors, if a parameter is not in that range you should output an error message and you should not change the corresponding color.

Write a main that asks color values from the user and creates one or more color objects. Your main should call each member function at least once.

image text in transcribed

12345678910111213141516/Aclassforsimulatinganintegermemorycell./classIntCe11{public:explicitIntCel1(intinitialValue=0):storedValue{initialValue}{}intread()const{returnstoredValue;}voidwrite(intx){storedValue=x;}private:intstoredValue;}; Figure 1.6 IntCe11 class with revisions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions