Question
Write a C++ program that asks the user to select a color and a shape to draw. In main, begin by declaring variables and displaying
Write a C++ program that asks the user to select a color and a shape to draw.
In main, begin by declaring variables and displaying the class header, and cout an explanation of the program. You may include this in your header or make it separate.
You will need constants for the maximum color number and for the maximum picture number as well as a value that indicates the user has finished drawing.
These will look like:
//Constants
const int QUIT{ 6};
const int MAX_COLORS{ 6};
const int MAX_PIX{3};
At this point, create a handle to the standard output device (the console) using: HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE); You will use this handle to access the screen to change colors. You will also need to #include
Open a do-while loop. This is the play loop. Provide a menu of colors and ask the user to select a color for the drawing. There will be 6 menu items, 5 colors, blue, green, cyan, red and purple. These will be selections 1-5. Selection 6 is to quit the drawing loop.
Use a while loop to check to make sure that the users answer is in the correct range of value, 1 6. If it is not, loop back and ask the user to re-enter their choice.
As long as the selection is not 6, present another menu and ask the user to select the picture to be drawn. There will be 3 pictures, a 1) smiling face, 2) a pyramid and 3) a picture of your choice. Check the input validity of that selection using a do while loop.
Use a switch structure to process the picture selection. Declare any variables you will use in the drawings up above the switch statement.
In each case statement, set the color using: SetConsoleTextAttribute(screen, colorChoice); Be sure to adjust the colorChoice value so that you will be drawing with the bright version of the color. It shows up so much better! Each picture will be drawn using the color selected by the user. Each picture can be drawn using symbols of your choice.
When the user selects 6 for the color selection, drop out of the loop, and show a good-bye message.
\begin{tabular}{|llll|} \hline Number & Text Color & Number & Text Color \\ \hline 0 & Black & 8 & Bright Black \\ \hline 1 & Blue & 9 & Bright Blue \\ \hline 2 & Green & 10 & Bright Green \\ \hline 3 & Cyan & 11 & Bright Cyan \\ \hline 4 & Red & 12 & Bright Red \\ \hline 5 & Purple & 13 & Bright Purple \\ \hline 6 & Yellow & 14 & Bright Yellow \\ \hline 7 & White & 15 & Bright White \\ \hline \end{tabular}Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started