Question: c++ * Be sure to add your name as a cout in the first lines of each program - else 0 credit. * Add constructors
c++
* Be sure to add your name as a cout in the first lines of each program - else 0 credit.
* Add constructors - a default and parameterized constructor to each.
* Write an .h interface and a .cpp implementation for each class
* Write an Drive/Test file that tests the constructors and functions
* Write a UML class diagram for each class
NOTE: It is REQURED that Each program must include this line:
cout << "Name: YOURNAME - Program Name: PROGRAM NAME - Date: MMDDYY" << endl;
Example: cout << "Name: Jon Smith - Program Name: Prog9Box - Date: 6/28/17" << end;
Run each program and Produce output -
--------------------------------------------------------------------------------------------
Program 4 - Pick color Class
Create a class that randomly pick a color from an array of colors: string colors[7];
Have the colors array and all functions defined in the class.
Create and use a void setElement( index, "color") function to assign values to the array elements 0 to 6: red, orange, yellow, green, blue, indigo, violet.
Have a function that prints out all the colors in the array.
Have a function that randomly pick One color from the array and cout's the color.
(Research Random number code)
Run your Code - Produce the correct output and Turn it in for credit
---------------------------------------------------------------------------------------
Program 5 Rectangle - Complete the following code
then run it - Produce the correct output and Turn it in for credit
// classes example #includeusing namespace std; class Rectangle { int width, height; public: void set_values (int,int); int area() { int answer; // complete this function so the code works return answer; } }; void Rectangle::set_values (int x, int y) { // complete this function so the code works } int main () { // Use this driver program
// Use set_values function to set values Rectangle rect1; rect1.set_values (5,6); cout << "area: " << rect1.area() << endl;
// Use set_values function to set values Rectangle rect2; rect2.set_values (3,4); cout << "area: " << rect2.area() << endl; return 0; }
-------------------------------------------------------------
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
