50 lines
826 B
C++
50 lines
826 B
C++
#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;
|
|
} |