#include <fstream>
#include <cmath>
#include <iostream>
using namespace std;

/*
    Header only definition of a small class of doing 1D classical mechanics.
*/

class Particle
{
  private:
   double mass,x,v;
 
  public:
 
// Different constructors allowing a Particle to be created.
 
   Particle() : mass(1.0), x(0.0), v(0.0)
      {
         cout << "Nu er vi i constructoren\n";
      }

   Particle(double xx)  : mass(1.0), x(xx), v(0.0)
      {
         cout << "Nu er vi i constructoren( position)\n";
      }

   Particle(double xx, double vv)   : mass(1.0), x(xx), v(vv)
      {
         cout << "Nu er vi i constructoren( position + hastighed)\n";
      }

   Particle(double xx, double vv, double mm) : mass(mm), x(xx), v(vv)
      {
         cout << "Nu er vi i constructoren( position + hastighed + masse)\n";
      }

// Methoder for getting / setting:

   void SetPos(double xx)
     {
        x=xx;
     }

   void SetVelocity(double vv)
     {
        v=vv;
     }

   double GetPos()
     {
        return x;
     }

   double GetVelocity()
     {
        return v;
     }

// Methods for doing physics

   double KineticEnergy()
     {
         return 0.5*mass*(v*v);
     }

   void Euler(double dt, double F)
     {
         x=x + dt*v;    
         v=v + dt*F/mass;
     }
};

