Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

c++ help

image text in transcribed

image text in transcribed

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. NOTE: I encourage you to try using uint8_t instead of int. But, int is good enough for the homework. 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 to Expert-Tailored 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

Recommended Textbook for

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions