#include<iostream>
using namespace std;
int main()
{
// Initialize variables
// Variables for loop to print multiple lines
char makeNewLine; // value will be either 'Y' or 'N'
int numLines=0;
// Variables to describe a single line
int lineSize;
char lineSymbol, lineDirection;
// lineDirection value either 'D', 'H', or 'V'
// Print welcome message
cout << "Welcome to line-builder\n";
// Get symbol to draw line
cout << "Please specify the type of character "
<< "to use in your lines: ";
cin >> lineSymbol;
// Loop for printing multiple lines
do {
// Increase counter for number of lines printed
numLines++;
// Get size of current line
cout << "Specify the size of your line: ";
cin >> lineSize;
// Get direction of line
cout << "Now specify the direction of your "
<< "line (h for horizontal, v for vertical, "
<< "d for diagonal): ";
cin >> lineDirection;
// Print line to screen
switch(lineDirection) {
// Horizontal case
case 'h' :
for (int i=1; i<=lineSize; i++)
cout << lineSymbol;
cout << endl;
break;
// Vertical case
case 'v' :
for (int i=1; i<=lineSize; i++)
cout << lineSymbol << endl;
break;
// Diagonal case
case 'd' :
for (int i=1; i<=lineSize; i++) {
// print the proper number of blank
// spaces for the given line
for (int numSpace=1; numSpace<i; numSpace++)
cout << " ";
// after enough spaces are printed for
// the given line, print out symbol
cout << lineSymbol << endl;
}
break;
// Not required part!
default :
cout << "Invalid direction option!\n";
} // end of switch(lineDirection)
// Ask if user wants to print another line
cout << "Would you like to print another line (Y/N)? ";
cin >> makeNewLine;
} while(makeNewLine=='Y');
// Say goodbye
cout << "Okay, thanks for printing " << numLines
<< " lines.\n";
return 0;
}