Question Please use visual studio software and display an output. Please help an
ID: 3765595 • Letter: Q
Question
Question Please use visual studio software and display an output. Please help and highlit or put in bold what you changed. Please I need help Modify the following program illustrated below after the question:(required: ShapeAnimator.cpp, SortAnimator.h) in which a Hat class is implemented. The main( ) must have an object of the Hat class instantiated to call the draw() member function. The moved( ) member function moves the triangle to top and bottom of the screen. The final solution should have : Zipped file of your solution and the executable project file.
Program:
#include '' ShapeAnimator.h ''
int main()
{ Tent tent(ll, 5, 13); Box box ( 5, 6 5, 4, 7 ) ;
tent.draw();
box.draw();
tent.draw();
box.draw();
for (int k = O; k <= 20; k++)
{ Sleep(75); tent.move(); box.move(); }
Shape *myShapes[] ={&tent, &box};
ComplexShape cS(myShapes, 2);
cS.setDirection(l, l);
for (int k = O; k < 12; k++) { Sleep(75); cs.move(); }
box.setDirection(O, 1); for (int k = O; k < 10; k ++)
{ }
Sleep(75);
box.move(); }
return 0; }
Progran for class Sort.Animator.h
#include <iostream>
#include <string>
#include <vector>
#include <windows.h>
using namespace std;
const HANDLE outHandle = GetStdHandle(STD_OUTPUT_HANDLE);
class Shape {
public:
virtual void setDirection(int drow, int dcol) const
{dRow = drow; dCol = dcol;}
void getDirection(int &drow, int &dcol)
{drow = dRow; dcol = dCol;}
virtual void move()= 0;
private:
int dRow, dCol;} ;;
{ public:
virtual void draw() const = 0;
void getPosition(int &row, int &col) const
{
row = rowPos; col = colPos;
}
void setPosition(int row, int col)
{ rowPos = row; colPos = col; }
void setColor(int c)
{ color = c;
} int getColor() const
{
return color;
} virtual void move();
private:
int color;
int rowPos, colPos;
} ;
class Box : public SimpleShape
{ public:
virtual void draw() const;
Box(int rowPos, int colPos, int width, int height);
private:
int width, height; } ;
class Tent : public SimpleShape
{ public: virtual void draw() const;
Tent(int baseRowPos, int baseColPos, int baseLength);
private: int baseLength; };
{
public: ComplexShape(Shape ** shapeCollection, int shapesCount);
virtual void move();
virtual void setDirection(int dRow, int dCol);
private: vector<Shape *> shapes; };
Program for Shape Animator.cpp
#include "ShapeAnimator.h"
#include <iostream>
#include <string>
#include <vector>
#include <windows.h>
using namespace std;
void SimpleShape::move()
{
int dRow, dCol;
int savedColor = color; color = 0;
draw();
getDirection(dRow, dCol);
rowPos += dRow;
colPos += dCol;
}
color = savedColor; draw();
void Tent:: draw() const
{
int rowPos, colPos;
COORD pas;
int currentLength = baseLength;
SetConsoleTextAttribute(outHandle, getColor());
getPosition(rowPos, colPos);
pos.Y = rowPos; pos.X = colPos;
for (int r = 0; r < (baseLength + 1); r++)
{
SetConsoleCursorPosition(outHandle,pos);
for (int k = 0; k < currentLength; k++)
{ cout << "*" ;
}
cout << endl;
pos.Y--; pos.X ++; currentLength - 2; }
SetConsoleTextAttribute(outHandle, 7); }
void Box::draw() const
{ int rowPos, colPos; COORD pos;
SetConsoleTextAttribute(outHandle, getColor());
getPosition(rowPos, colPos);
pos.X = colPos; pos.Y = rowPos;
for (int r = 0; r < height; r++)
{
SetConsoleCursorPosition(outHandle, pos); for (int c = 0; c < width; c++) {
} cout<< " *" ;
cout << endl;
pos.Y++;
}
SetConsoleTextAttribute(outHandle, 7);
}
Box::Box(int rowPos, int colPos, int width, int height)
{ setColor(4); } setPosition(rowPos, colPos); this->width = width;
this->height = height; draw();
Tent::Tent(int baseRowPos, int baseColPos, int baseLength)
{ setColor(2); setPosition(baseRowPos, baseColPos);
this->baseLength = baseLength; draw(); }
ComplexShape::ComplexShape(Shape ** shapeCollection, int shapesCount)
{ Shape *p;
for (int k = O; k < shapesCount; k++)
p = shapeCollection[k]; shapes.push)_back(p);
}
}
void ComplexShape::move()
{
for (int k = O; k < shapes.size(); shapes[k]->move();
k++)
}
void ComplexShape::setDirection(int dRow, int dCol)
{ Shape::setDirection(dRow, dCol);
for (int k = O; k < shapes.size(); k++)
shapes[k]->setDirection(dRow, dCol); }
Explanation / Answer
Hi, I have marked the changes in bold. Please follow. Your code seems good, and error-free mostly. AMinly there are sysntactical errors. I have corrected/marked them for you. Have a close look :)
#include '' ShapeAnimator.h ''
int main()
{
Tent tent(ll, 5, 13);
Box box ( 5, 6 5, 4, 7 ) ;
tent.draw();
box.draw();
//Remove these two lines
tent.draw();
box.draw();
for (int k = O; k <= 20; k++)
{ Sleep(75); tent.move(); box.move(); }
Shape *myShapes[] ={&tent, &box};
ComplexShape cS(myShapes, 2);
cS.setDirection(l, l);
for (int k = O; k < 12; k++) { Sleep(75); cs.move(); }
box.setDirection(O, 1);
for (int k = O; k < 10; k ++)
{ }
Sleep(75);
box.move(); }
return 0; }
class Shape {
public:
virtual void setDirection(int drow, int dcol) const
{dRow = drow; dCol = dcol;}
void getDirection(int &drow, int &dcol)
{drow = dRow; dcol = dCol;}
virtual void move()= 0;
private:
//handle the semi-colons perfectly..two semi-colons not required. Remove one
int dRow, dCol;} ;;
{ public:
virtual void draw() const = 0;
void getPosition(int &row, int &col) const
{
row = rowPos; col = colPos;
}
void setPosition(int row, int col)
{ rowPos = row; colPos = col; }
void setColor(int c)
{ color = c;
} int getColor() const
{
return color;
} virtual void move();
private:
int color;
int rowPos, colPos;
} ;
class Box : public SimpleShape
{ public:
virtual void draw() const;
Box(int rowPos, int colPos, int width, int height);
private:
int width, height; } ;
class Tent : public SimpleShape
{ public: virtual void draw() const;
Tent(int baseRowPos, int baseColPos, int baseLength);
private: int baseLength; };
{
public: ComplexShape(Shape ** shapeCollection, int shapesCount);
virtual void move();
virtual void setDirection(int dRow, int dCol);
private: vector<Shape *> shapes; };
void SimpleShape::move()
{
int dRow, dCol;
int savedColor = color; color = 0;
draw();
getDirection(dRow, dCol);
rowPos += dRow;
colPos += dCol;
}
color = savedColor; draw();
void Tent:: draw() const
{
int rowPos, colPos;
COORD pas;
int currentLength = baseLength;
SetConsoleTextAttribute(outHandle, getColor());
getPosition(rowPos, colPos);
pos.Y = rowPos; pos.X = colPos;
for (int r = 0; r < (baseLength + 1); r++)
{
SetConsoleCursorPosition(outHandle,pos);
//move the object
for (int k = 0; k < currentLength; k++)
{ cout << "*" ;
}
cout << endl;
pos.Y--; pos.X ++; currentLength - 2; }
SetConsoleTextAttribute(outHandle, 7); }
void Box::draw() const
{ int rowPos, colPos; COORD pos;
SetConsoleTextAttribute(outHandle, getColor());
getPosition(rowPos, colPos);
pos.X = colPos; pos.Y = rowPos;
for (int r = 0; r < height; r++)
{
SetConsoleCursorPosition(outHandle, pos); for (int c = 0; c < width; c++) {
} cout<< " *" ;
cout << endl;
pos.Y++;
}
SetConsoleTextAttribute(outHandle, 7);
}
Box::Box(int rowPos, int colPos, int width, int height)
{ setColor(4); } setPosition(rowPos, colPos); this->width = width;
this->height = height; draw();
Tent::Tent(int baseRowPos, int baseColPos, int baseLength)
{ setColor(2); setPosition(baseRowPos, baseColPos);
this->baseLength = baseLength; draw(); }
ComplexShape::ComplexShape(Shape ** shapeCollection, int shapesCount)
{ Shape *p;
for (int k = O; k < shapesCount; k++)
p = shapeCollection[k]; shapes.push)_back(p);
}
}
//Improve your move moethod
void ComplexShape::move()
{
for (int k = O; k < shapes.size(); k++)
shapes[k]->move();
}
void ComplexShape::setDirection(int dRow, int dCol)
{ Shape::setDirection(dRow, dCol);
for (int k = O; k < shapes.size(); k++)
shapes[k]->setDirection(dRow, dCol);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.