Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef COLOR_H
- #define COLOR_H
- #include <iostream>
- using namespace std;
- //NOTE: red, green, and blue must be within the range of [0,255]
- // if any are out of range, assign either 0 or 255 (whichever is closest)
- // i.e., if value is negative, assign 0
- // if value > 255, assign 255
- // done through ckRange(...)
- class Color
- {
- public:
- Color(); //default constructor
- Color(int redVal, int greenVal, int blueVal);//constructor taking rgb
- void setRed(int redVal); // set red value
- void setGreen(int greenVal); // set green value
- void setBlue(int blueVal); // set blue value
- int getRed() const; // gets red value
- int getGreen() const; // gets green value
- int getBlue() const; // gets blue value
- void read(istream& ins); // in the order of red green blue
- void write(ostream& outs) const;
- private:
- int red, green, blue;
- int ckRange(int val); // you also need to implement this one
- };
- istream& operator >> (istream& ins, Color& color);
- ostream& operator << (ostream& outs, Color color);
- #endif
Advertisement
Add Comment
Please, Sign In to add comment