subject

Modify the following Program. Convert the following program as per comments // program colors

// -> Convert class into .h header file and .ccp implemenation file.
// Keep int main() funciton same...
#include
using namespace std;
#include
/* srand example */
#include
#include /* NULL */
#include /* srand, rand */
class colorPicker {
private:
string colorArray[7];
public:
colorPicker() {
// Defalut Consructor assign values to array

colorArray[0] ="Red";
colorArray[1] ="Green";
colorArray[2] ="Purple";
colorArray[3] ="Yellow";
colorArray[4] ="Orange";
colorArray[5] ="Indigo";
colorArray[6] ="Pink";

}
void printAllColors() {
// use for loop to print out all colors
for (int i = 0 ;i < 7; i++)
{ cout << colorArray[i] << endl;}
}

string randomColor() {
srand((unsigned)time(0));
// pick a random number between 1 and 7
int i =0;
i = rand()%7;
return colorArray[i];
}
};
int main()
{
colorPicker P;
//

P. printAllColors();

cout << "Random Color: " << P. randomColor();

system("pause");

return 0;

}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 17:30, staz13wiggins
How many pairs of chromosomes do human body cells contain?
Answers: 2
image
Computers and Technology, 21.06.2019 19:30, Margieeee
Asalesman at a high end computer security firm want to sell you a proactive cover for your passport, which contains an rfid tag inside storing your sensitive information. the salesperson's solution cost only $79.99 and protects your passport from being read via radio waves while it is in your pocket. explain how you can achieve the same thing under $3.00
Answers: 3
image
Computers and Technology, 22.06.2019 01:30, yudayang2012pa9u8p
Consider the following statements: #include #include class temporary { private: string description; double first; double second; public: temporary(string = "", double = 0.0, double = 0.0); void set(string, double, double); double manipulate(); void get(string& , double& , double& ); void setdescription(string); void setfirst(double); void setsecond(double); }; write the definition of the member function set() so that the instance variables are set according to the parameters. write the definition of the constructor so that it initializes the instance variables using the function set() write the definition of the member function manipulate() that returns a decimal number (double) as follows: if the value of description is "rectangle", it returns first * second if the value of description is "circle" it returns the area of a circle with radius first if the value of description is "cylinder" it returns the volume of a cylinder with radius first and height second. hint: the volume of a cylinder is simply the area of the circle at the base times the height. if the value of description is "sphere" it returns the volume of the sphere with radius first. otherwise it returns -1.0;
Answers: 1
image
Computers and Technology, 22.06.2019 13:30, ReaLily
1. technician a says horsepower information can be used by consumers to compare the power of different automobile engines. technician b says that manufacturers will often list the horsepower output of their engines in the online service information. who is right?
Answers: 2
You know the right answer?
Modify the following Program. Convert the following program as per comments // program colors
...

Questions in other subjects:

Konu
Mathematics, 19.09.2021 04:50
Konu
History, 19.09.2021 04:50