The document describes an assignment to build a menu system and drawing routines that will allow a user to select and view different ASCII art shapes of specified sizes. The menu will prompt the user to select a command and will validate the input. If invalid, it will re-prompt. Supported commands include help, quit, and commands to draw shapes like square, box, diagonal lines, and a checkerboard. Each shape drawing will then prompt the user to enter a valid size and draw the selected shape. Tips are provided on an iterative development approach.
OverviewFor this assignment you will be building two main co.docx
1. Overview
For this assignment you will be building two main components.
A menu system and several drawing routines.
The menu system will operate on a whitelist principle and
prompt the user for the type of drawing they want and its size.
A
whitelist
is a list of accepted inputs with anything not on the list
rejected.
The drawings will all be ASCII shapes of user specified size.
Menu System
The menu should prompt the user for a command and if it is not
a valid command, respond it is invalid and prompt again. The
commands it needs to respond include:
help - This will print a list of all accepted inputs and re-prompt
the user.
quit - This will terminate the program.
square - This will initiate the square drawing.
box - This will initiate a box drawing.
diagonaldown - This will initiate a diagonal down line.
diagonalup - This will initiate a diagonal up line.
2. checkerboard - This will initiate a checkerboard pattern.
The matching for the commands should be case insensitive. That
is "Help", "help", and "hElP" will all trigger the help command.
Drawings
There are several drawings that your program needs to support
Square
When a square is drawn it will first prompt the user for a size.
Valid sizes are 1 through 15 inclusive. An example square of
size 5 is
*****
*****
*****
*****
*****
Box
When a box is drawn it will first prompt the user for a size.
Valid sizes are 3 through 15 inclusive. An example box of size
5 is
*****
* *
3. * *
* *
*****
Diagonal Down
When a diagonal down line is drawn, it will first prompt the
user for a size. Valid sizes are 3 through 15 inclusive. An
example line of size 5 is
*
*
*
*
*
Diagonal Up
When a diagonal up line is drawn, it will first prompt the user
for a size. Valid sizes are 3 through 15 inclusive. An example
line of size 5 is
*
*
*
*
4. *
Checkerboard
When a checkerboard drawn, it will first prompt the user for a
size. Valid sizes are 5 through 15 inclusive. An example line of
size 10 is
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
Tips
Write your program iteratively. You shouldn't ever write more
than a few lines of code without compiling and testing it.
Start with small pieces. It isn't reasonable to sit down and write
5. the whole program from beginning to end. The pieces you build
should ultimately fit together to build the whole program.
It is easiest to draw the various shapes using nested for loops.
One way to build the program is as follows:
Write a function that accepts user input and validates it against
the list of command. Start with it being case sensitive and then
add case insensitivity.
Write the functionality to print out a help message, quit, and re-
prompting the user on invalid input.
Start with one of the drawings, say a square. Create a function
to draw a square. Initially make it draw a fixed size, then allow
for it to draw an arbitrary size.
Write a function to prompt the user for a size within a specified
range. This function should validate the input is in the specified
range and re-prompt if it is outside. Make sure to write this
function so that it can be used for multiple drawings which may
have different size constraints.
Integrate your size prompt function to fully draw your first
chosen shape.
At this point your program should have close to full
functionality, with the only thing missing being other shapes.
Add the remaining shapes to the program using the
infrastructure you have already built.
6. Example Output
User input is in bold
Please enter a command:
bad
Invalid command
Please enter a command:
hElP
Acceptable commands: help, quit, square, box, diagonaldown,
diaonalup, checkerboard
Please enter a command:
square
Please enter a size between 1 and 15:
-1
The value -1 is not in a valid range.
Please enter a size between 1 and 15:
16
The value 16 is not in a valid range.
Please enter a size between 1 and 15:
5
*****
*****
7. *****
*****
*****
Please enter a command:
box
Please enter a size between 3 and 15:
2
The value 2 is not in a valid range.
Please enter a size between 3 and 15:
5
*****
* *
* *
* *
*****
Please enter a command:
diagonaldown
Please enter a size between 3 and 15:
7