From c00ec138f33b71b16ca5a4761e36b7b27b2c693f Mon Sep 17 00:00:00 2001 From: Inex Code Date: Sat, 19 Sep 2020 13:16:55 +0000 Subject: [PATCH] hw1 task3 draft --- Hw1/task3.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Hw1/task3.cpp diff --git a/Hw1/task3.cpp b/Hw1/task3.cpp new file mode 100644 index 0000000..60d2f53 --- /dev/null +++ b/Hw1/task3.cpp @@ -0,0 +1,50 @@ +#include +#include +#include + +using namespace std; + +// TODO: finish implementation +class Hop { +private: + double maxheight, startVelocity, startTime; + bool isHalfed; + const double loss = 0.7; + const double g = 10; + +public: + Hop(double initHeight, bool starter); + ~Hop(); + double hopTime(); + double getPosition(double time); + double getVelocity(double time); +}; + +Hop::Hop(double initHeight, bool starter) +{ + maxheight = initHeight; + isHalfed = starter; + startTime = 0; + startVelocity = 0; +} + +double Hop::hopTime() +{ + if (isHalfed) + return sqrt((2 * maxheight) / g); + return 2 * sqrt((2 * maxheight) / g); +} + +double Hop::getPosition(double time) +{ + return time * startVelocity - g * time * time / 2; +} + +Hop::~Hop() +{ +} + +int main() +{ + return 0; +} \ No newline at end of file