Ok this is where i'm at
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#include<iostream>
#include<conio.h>
#include<limits>
using namespace std;
// Global Variables
int length, headWidth, tailWidth;
char drawChar;
int repeatMeasurements;
int printArrow()
{
// Variables limited to this function
int headLength, tailLength;
headLength = length / 2 + 1;
tailLength = length - headLength;
//This will create the ArrowHead
// This will create the top section of the arrow , 1 Draw char top row followed by +2 each following row
for (int height = 1; height <= headWidth; height += 2)
{
//Going from bottom up minusing 2 spaces as it goes
for (int spaces = headWidth; spaces > height; spaces -= 2)
{
//output spaces
cout << " ";
}
for (int spaces = 0; spaces < height; spaces++)
{
cout << drawChar; //Prints Symbol
}
cout << endl;
}
// This will create the tail of the arrow
//Arrow Tail
for (int r = 0; r < tailLength; r++)
{
for (int c = 0; c < tailWidth; c++)
{
// Prints spaces untill the columns is equal to tailwidth
if (r > headWidth / 2 + 1 || c >= length / tailLength || c <= headLength)
{
cout << drawChar; //print symbol
}
else
{
cout << ' '; //Print space
}
}
cout << endl;
}
//function must return value
return 0;
}
int RepeatArrow()
{
return repeatMeasurements;
}
//Starting Menu Function
int userchoice()
{
cout << "Please choose an option:\n";
cout << "\t1. Create an arrrow: \n ";
cout << "\t2. Repeat the last measurements? \n ";
cout << "\t3. Exit\n";
int input;
cin >> input;
if (input == 1 || input == 2 || input == 3)
{
cout << "Please continue.\n";
}
else
{
cin.clear();
cout << "Error: Please select another option\n";
}
return input;
}
int main()
{
bool KeepRunning = true;
while (KeepRunning)
{
//Runs the Menu Function
int selection = userchoice();
switch (selection)
{
case 1:
cout << "Please enter the height:\n";
cin >> length;
cout << "Please enter the headWidth:\n";
cin >> headWidth;
cout << "Please enter the tailWidth:\n";
cin >> tailWidth;
cout << "Please enter the character you would like to render the arrow with:\n";
cin >> drawChar;
printArrow();
break;
case 2:
RepeatArrow();
break;
case 3:
KeepRunning = false;
break;
}
}
return 0;
}
|
Seems to be working except for one thing, the tail is not correct.. any ideas whats wrong with it? Just prints it to the left . So the arrow is still messed up, also i need to give an option for repeating the inputs, not sure how to do that either!
Also im being graded on my IPO and psuedo Code..
Gregory Cornes
Student Number : 14036637
Task A Arrowhead
Input Processing Output
Length /2+1 Headlength
Length -headLength Taillength
Psuedo Code
1. Ask user for inputs (headWidth, tailWidth, length, drawchar)
2. Read user inputs
3. Calculate Head Length = length / 2 + 1
4. Calculate Tail Length = length - headLength
5. Print Arrowhead
Output draw char for long as height less than or equal to headWidth starting with 1 increasing by 2.
Output Spaces from bottom of arrow head subtracting - 2 each row
6. Print ArrowTail
Create Rows = taillength
Create Colums = tailWidth
Task B Menu Systems and Repeats
Psuedo Code
1. Ask user for selection
2. If Option 1, Go to Task A
3. If Option 2, Repeat Inputs from task A
4. If Option 3, Exit the Program