hw1 task3 draft
This commit is contained in:
parent
bbede5b1e9
commit
c00ec138f3
50
Hw1/task3.cpp
Normal file
50
Hw1/task3.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in a new issue