Project Description:
C++ assignment . test it in microsoft virtual studio to make sure it runs before you send it back to me
Attached Code:
0 0 0 5 10 -5 2 3 -4
-10 5 10 0 -10 5 5 -2 0
(Chavez Siles, Feraidon, Nguyen, Walsh)
Create a class called "RGB" for representing the RGB color code of any color. Include the following:
1) Attributes (all integers): a number from 0 to 255 for each of red (R), green (G), and blue (B).
2) Default constructor: all attributes are set to zero.
3) Initial value constructor.
4) Accessors and mutators for all attributes.
5) A method for calculating the "distance" between two points. The smaller the distance, the more similar two colors are. This is done by representing R, G, and B as the x, y, and z coordinates in a 3D coordinate system. Overload an operator if you'd like.
6) A method for converting the RGB values of a color into their hexadecimal equivalent. For each color, you're essentially converting 3 base-10 numbers into 3 base-16 numbers. The best way to do this is to represent the hexadecimal equivalent as a character array. However, the array has to be dynamic, both in the main function and in the method. Use the following as a guide:
#include
using namespace std;
char *myfun(int R, int G, int B);
int main()
{
int red=255, green=255, blue=255;
char *hex_equiv;
hex_equiv = new char[6];
hex_equiv = myfun(red,green,blue);
cout<<hex_equiv[0]<<hex_equiv[1]<<hex_equiv[2]<<hex_equiv[3]<<hex_equiv[4]<<hex_equiv[5]<<endl;
return 0;
}
char *myfun(int R, int G, int B)
{
char *hex;
hex = new char[6];
hex[0] = 'F';
hex[1] = 'F';
hex[2] = 'F';
hex[3] = 'F';
hex[4] = 'F';
hex[5] = 'F';
return hex;
}
The attached file contains 6 integers: the R, G, and B values for color 1, and the values for color 2. Read the data and create a formatted output file with the R, G, and B values for each color, their hexadecimal equivalents, and the distance between the two colors.