This is our opening project on Classes so I looked over Point.h/Point.cpp which we did in class and followed those forms here. But, it is obvious I am making lots of mistakes. I have looked over the Classes page on the site and watched some videos... Could anyone here help me get started with fixing these issues?
#include "Color.h"
Color::Color()
{
red = 0;
green = 0;
blue = 0;
}
Color::Color(int redVal, int greenVal, int blueVal)
{
red = redVal;
green = greenVal;
blue = blueVal;
}
void Color::setRed(int redVal)
{
red = redVal;
}
#ifndef COLOR_H
#define COLOR_H
#include <iostream>
usingnamespace 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