Question: Write a program that displays an inchwork on the left hand side of the screen, facing right. Then slowly move them across the screen until

Write a program that displays an inchwork on the left hand side of the screen, facing right. Then slowly move them across the screen until they disappear off the right-hand side. You may wish to do this in a loop so that after disappearing to the right, the work appears again on the left. The diagram below show how they may look at various points on the screen.

Write a program that displays an inchwork on the left hand side

Here is what I have done so far, and I don't know why it doesn't work

#include #include #include #include #include #include

using namespace std;

class Inchworm {

private:

int x;

int y;

int z;

public:

Inchworm();

void CGoto_Co();

void Get_Cursor();

};

Inchworm::Inchworm() {

x = 0;

y = 0;

z = 0;

}

void Inchworm::CGoto_Co() {

COORD co = { x,y };

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), co);

return;

}

void setCursor_To(int x, int y)

{

HANDLE handle;

COORD position;

handle = GetStdHandle(STD_OUTPUT_HANDLE);

position.X = x;

position.Y = y;

SetConsoleCursorPosition(handle, position);

}

void Inchworm::Get_Cursor() {

CONSOLE_SCREEN_BUFFER_INFO csbi;

if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) {

x = csbi.dwCursorPosition.X;

y = csbi.dwCursorPosition.Y;

cout

cout

cout

//a++;

//b++;

//cout

}

}

int main() {

Inchworm slither;

slither.CGoto_Co();

slither.Get_Cursor();

}

- 0000 0000 -000000000 000000000- 00 000 000- 00 000 00 0 0000 0000- 000 A 00 V V V

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!