From 16ca18d8d125e0a71b25f6bb2c2e8b9afa91d9ff Mon Sep 17 00:00:00 2001 From: Jonathan Harker Date: Wed, 3 Mar 2021 17:17:39 +1300 Subject: [PATCH] Add some comments. --- source/app.d | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/app.d b/source/app.d index d21ebe1..31fd9c2 100644 --- a/source/app.d +++ b/source/app.d @@ -11,9 +11,12 @@ const double internalInjuries = 25.0; const double fatal = 40.0; const double puree = 100.0; -const Acceleration g = 9.8 * metre / second /second; // about 35.3 km/h/s +const Acceleration g = 9.8 * metre / second / second; // about 35.3 km/h/s const Mass typicalHuman = 80 * kilogram; +/++ + + Prompt the user for a plausible number from stdin. + +/ double getVelocity() { string v = ""; while (!isNumeric(v)) { @@ -24,6 +27,7 @@ double getVelocity() { } void main(string[] argv) { + // Fetch a number from a cli argument, or prompt for one from stdin. double velocity = 0; auto args = getopt(argv, "velocity|v", "How fast The Flash was going", &velocity @@ -43,6 +47,7 @@ void main(string[] argv) { Force f = typicalHuman * a; double accel_g = a / g; + // Output some opinionated results. writefln("The Flash goes from stand-still to %s in a tenth of a second, thus accelerating at %.1f g.", "%.0f km/h".siFormat(v), accel_g); writefln("This would exert a force of %s on a typical human body.", "%.1f kN".siFormat(f));