0
#include<iostream>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<windows.h>
using namespace std; 

void z()
{
    Sleep(100);
} 

class Car
{
    double fuel;
    double speed;
    double X;
    double Y;
public:
    Car(double n, char *type)
    {
        fuel=n;
        speed=120;
    }
    double Speed()
    {
        return speed;
    }
    void Position(double p, double q)
    {
        X = p;
        Y = q;
    }
    void Move()
    {
        X=X+(Speed()/3600);
        Y=Y+(Speed()/3600);
    }
};
int main()
{
    Car c(70,"Car");
    double x,y;
    c.Position(3.2,2.2);
    cout<<c.Speed()<<endl;
    while(1)
    {
        c.Move();
        c.Position(x,y);
        cout<<x<<","<<y<<endl;
        z();
    }
    return 0;
}

I want to show the changes of position in the same line that means in each second the value of position will be updated and show it in the same line replacing the older value but will not create any new line.

IAmBlake
  • 457
  • 6
  • 21

0 Answers0