#include <sstream> // For stringstream class #include <Color.hpp> // For Color c
ID: 3762416 • Letter: #
Question
#include <sstream> // For stringstream class
#include <Color.hpp> // For Color class
// Write the function definitions for each of the function members of the Color class.
//--------------------------------------------------------------------------------------------------------------
// CTOR: Color::Color()
//
// DESCRIPTION:
// Initializes the color to black by initializing mRed, mGreen, and mBlue to 0, 0, and 0.
//
// PSEUDOCODE:
// Call init() passing 0, 0, 0 as the arguments.
//--------------------------------------------------------------------------------------------------------------
???
//--------------------------------------------------------------------------------------------------------------
// CTOR: Color::Color()
//
// DESCRIPTION:
// Initializes the color initializing mRed, mGreen, and mBlue to pInitRed, pInitGreen, and pInitBlue.
//
// PSEUDOCODE:
// Call init() passing pInitRed, pInitGreen, and pInitBlue as the arguments.
//--------------------------------------------------------------------------------------------------------------
???
//--------------------------------------------------------------------------------------------------------------
// FUNCTION: getBlue()
//
// DESCRIPTION:
// Accessor function for the mBlue data member.
//
// PSEUDOCODE:
// Return mBlue
//--------------------------------------------------------------------------------------------------------------
???
//--------------------------------------------------------------------------------------------------------------
// FUNCTION: getGreen()
//
// DESCRIPTION:
// Accessor function for the mGreen data member.
//
// PSEUDOCODE:
// Return mGreen
//--------------------------------------------------------------------------------------------------------------
???
//--------------------------------------------------------------------------------------------------------------
// FUNCTION: getRed()
//
// DESCRIPTION:
// Accessor function for the mRed data member.
//
// PSEUDOCODE:
// Return mRed
//--------------------------------------------------------------------------------------------------------------
???
//--------------------------------------------------------------------------------------------------------------
// FUNCTION: setBlue()
//
// DESCRIPTION:
// Mutator function for the mBlue data member.
//
// PSEUDOCODE:
// mBlue <- pNewBlue
//--------------------------------------------------------------------------------------------------------------
???
//--------------------------------------------------------------------------------------------------------------
// FUNCTION: setGreen()
//
// DESCRIPTION:
// Mutator function for the mGreen data member.
//
// PSEUDOCODE:
// mGreen <- pNewGreen
//--------------------------------------------------------------------------------------------------------------
???
//--------------------------------------------------------------------------------------------------------------
// FUNCTION: setRed()
//
// DESCRIPTION:
// Mutator function for the mRed data member.
//
// PSEUDOCODE:
// mRed <- pNewRed
//--------------------------------------------------------------------------------------------------------------
???
//--------------------------------------------------------------------------------------------------------------
// FUNCTION: toString()
//
// DESCRIPTION:
// Returns a string representation of this Color in the form "(mRed, mGreen, mBlue)". For example, if mRed = 12,
// mGreen = 100, and mBlue = 212, then this function would return the string "(12, 100, 212)".
//
// PSEUDOCODE:
// Define a stringstream object named sout
// Send to sout "(" getRed() ", " getGreen() ", " getBlue() ")"
// Return sout.str()
//--------------------------------------------------------------------------------------------------------------
???
//--------------------------------------------------------------------------------------------------------------
// FUNCTION: init()
//
// DESCRIPTION:
// Initializes the data members to the parameters by calling the mutator functions.
//
// PSEUDOCODE:
// setRed(pInitRed)
// setGreen(pInitGreen)
// setBlue(pInitBlue)
//--------------------------------------------------------------------------------------------------------------
???
Explanation / Answer
//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 color.cpp // Color class implementation #include "color.h" #include using namespace std; // Member Functions... // Set color void color::readColor(color c) { cColor = c; } void color::writeColor() const { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.