Guest User

Untitled

a guest
Dec 10th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #ifndef COLOR_H
  2. #define COLOR_H
  3.  
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. //NOTE: red, green, and blue must be within the range of [0,255]
  8. // if any are out of range, assign either 0 or 255 (whichever is closest)
  9. // i.e., if value is negative, assign 0
  10. // if value > 255, assign 255
  11. // done through ckRange(...)
  12.  
  13.  
  14. class Color
  15. {
  16. public:
  17. Color(); //default constructor
  18. Color(int redVal, int greenVal, int blueVal);//constructor taking rgb
  19. void setRed(int redVal); // set red value
  20. void setGreen(int greenVal); // set green value
  21. void setBlue(int blueVal); // set blue value
  22.  
  23. int getRed() const; // gets red value
  24. int getGreen() const; // gets green value
  25. int getBlue() const; // gets blue value
  26.  
  27. void read(istream& ins); // in the order of red green blue
  28. void write(ostream& outs) const;
  29.  
  30. private:
  31. int red, green, blue;
  32. int ckRange(int val); // you also need to implement this one
  33.  
  34.  
  35. };
  36.  
  37. istream& operator >> (istream& ins, Color& color);
  38. ostream& operator << (ostream& outs, Color color);
  39. #endif
  40.  
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment