Guest User

Untitled

a guest
Dec 10th, 2011
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include "Color.h"
  2.  
  3. Color::Color()
  4. {
  5. red = 0;
  6. green = 0;
  7. blue = 0;
  8.  
  9. }
  10.  
  11. Color::Color(int redVal, int greenVal, int blueVal)
  12. {
  13. red = redVal;
  14. green = greenVal;
  15. blue = blueVal;
  16.  
  17. }
  18.  
  19. void Color::setRed(int redVal)
  20. {
  21. red = redVal;
  22. }
  23.  
  24. void Color::setGreen(int greenVal)
  25. {
  26. green = greenVal;
  27. }
  28.  
  29. void Color::setBlue(int blueVal)
  30. {
  31. blue = blueVal;
  32. }
  33.  
  34. int Color::getRed() const
  35. {
  36. return red;
  37. }
  38.  
  39. int Color::getGreen() const
  40. {
  41. return green;
  42. }
  43.  
  44. int Color::getBlue() const
  45. {
  46. return blue;
  47. }
  48.  
  49. int Color::ckRange(int val)
  50. {
  51. if(val > 255)
  52. {
  53. val = 255;
  54. return val;
  55. }
  56. if(val < 0)
  57. {
  58. val = 0;
  59. return val;
  60. }
  61. }
  62.  
  63.  
  64. void Color::read(istream& ins)
  65. {
  66. //check these later
  67. ins >> red >> green >> blue;
  68. }
  69.  
  70.  
  71.  
  72.  
  73. void Color::write(ostream& outs) const
  74. {
  75. outs << " " << red << " " << green << " " << blue << " " ;
  76. }
  77.  
  78. istream& operator >> (istream& ins, Color& color)
  79. {
  80. color.read(ins);
  81. return ins;
  82. }
  83.  
  84. ostream& operator << (ostream& outs, Color color)
  85. {
  86. color.write(outs);
  87. return outs;
  88. }
  89.  
  90.  
  91.  
Advertisement
Add Comment
Please, Sign In to add comment