summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Williams <[email protected]>2022-10-13 17:07:51 -0700
committerJoseph Williams <[email protected]>2022-10-13 17:07:51 -0700
commitf121263d0df0c2cacd5aac0897fff282383ebab5 (patch)
tree5adb70f8d67e436d67765f7db024eba3169779a6
parentCompleted steps 3-5 (compute area, convert to square meters, print to user). ... (diff)
downloadcst116-lab1-allthenamesaretaken3141-f121263d0df0c2cacd5aac0897fff282383ebab5.tar.xz
cst116-lab1-allthenamesaretaken3141-f121263d0df0c2cacd5aac0897fff282383ebab5.zip
Completed step 6 (warn user about bad aspect ratio).
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index 2390a6e..79d0037 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -41,9 +41,9 @@ float getWidthOrHeight(string d)
float input;
vector<tuple< string, int, bool> > text;
text.push_back(make_tuple("Please enter the ", 15, false));
- text.push_back(make_tuple(d, 13, false));
+ text.push_back(make_tuple(d, 11, false));
text.push_back(make_tuple(" of your kite in ", 15, false));
- text.push_back(make_tuple("cm", 13, false));
+ text.push_back(make_tuple("cm", 11, false));
text.push_back(make_tuple(": ", 15, false));
while (true)
{
@@ -65,26 +65,43 @@ float calulateKiteArea(float width, float height)
return ((width * height) / 2) / 10000;
}
+//Computes and prints aspect ratio
+void aspectRatio(float width, float height)
+{
+ float ratio = width / height;
+ multiColorPrint(vector<tuple<string, int, bool> > {make_tuple("Your kite has an aspect ratio of ", 15, false), make_tuple(to_string(ratio), 11, false), make_tuple(". ", 15, false)});
+ if (ratio >= 1) {
+ colorPrint("Your kite will fly nice and stable...provided that you do, in fact, actually know how to fly it.", 10);
+ }
+ else
+ {
+ colorPrint("Your kite is too wide and will be unstable. Or you could just, like, fly it sideways or something.", 6);
+ }
+}
+
int main()
{
float width, height;
- colorPrint("Welcome to Kite Calculator!\n", 11);
+ colorPrint("Welcome to Kite Calculator. I still don't know why I agreed to this job.\n", 13);
- colorPrint("Let's start with getting the dimensions of your kite. Or not, I wouldn't mind a break.", 9);
+ colorPrint("Let's start with getting the dimensions of your kite. Or not. I wouldn't mind a break.", 9);
width = getWidthOrHeight("width");
height = getWidthOrHeight("height");
cout << endl;
//Tell the user what they just entered, because...reasons.
- colorPrint("Great job. You can type numbers on a keyboard. I'm soooo proud of you.", 10);
- multiColorPrint(vector<tuple<string, int, bool> > {make_tuple("Your kite is ", 15, false), make_tuple(to_string(width) + "cm", 13, false), make_tuple(" wide and ", 15, false), make_tuple(to_string(height) + "cm", 13, false), make_tuple(" high.", 15, true), }); //I hate this but its still better than stacking like 20 couts.
+ colorPrint("Great job. You can type numbers on a keyboard. I'm so proud of you.", 10);
+ multiColorPrint(vector<tuple<string, int, bool> > {make_tuple("Your kite is ", 15, false), make_tuple(to_string(width) + "cm", 11, false), make_tuple(" wide and ", 15, false), make_tuple(to_string(height) + "cm", 11, false), make_tuple(" high.", 15, true), }); //I hate this but its still better than stacking like 20 couts.
colorPrint("I'm sure it's beautiful. Or maybe not. I don't know you.\n", 9);
//Calculate the kite's area and tell it to the user.
float area = calulateKiteArea(width, height);
- multiColorPrint(vector<tuple<string, int, bool> > {make_tuple("Your kite has an area of ", 15, false), make_tuple(to_string(area) + " square meters", 11, false), make_tuple(". ", 15, false), make_tuple("Remind me why I agreed to do this, again?", 9, true)});
+ multiColorPrint(vector<tuple<string, int, bool> > {make_tuple("Your kite has an area of ", 15, false), make_tuple(to_string(area) + " square meters", 11, false), make_tuple(". ", 15, false), make_tuple("...I don't get paid enough for this.", 9, true)});
cout << endl;
+ //Do aspect ratio stuff.
+ aspectRatio(width, height);
+
return 0;
} \ No newline at end of file