SlideShare a Scribd company logo
Please make the complete program, Distinguish between header files and class files. I give three
of the classes below, but I do not know if they are complete.I already posted this question before,
but the answer was incorreect. ask any questions if you need any help.
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
-----------------------------------
Section 1: Project Objectives
By given a class hierarchy, focus on Object-Oriented-Design concept, design and write multiple
classes.
Be able to apply the concepts of inheritance, polymorphism, abstract classes, pure virtual
functions, function overriding, etc.
Be familiar with common functions in vector class in C++.
Section 2: Background Introduction
Video game programmers often have to maintain a collection of figures that are simultaneously
moving in various directions on the screen. In this project, we will design a solution to a
simplified version of the problem.
We will maintain a collection of geometric shapes and simultaneously animate those shapes. The
functions used to directly access the screen and manage the timer are peculiar to Microsoft
Windows, but the principles used are very general and are applicable to all operating systems.
Section 3: Project Description
We begin with a class that represents a shape that is able to move in any of eight different
directions, with each direction being specified by a pair of integer (X, Y) coordinates. Upward or
downward motion is indicated by a Y component of ±1. A value of 0 for an X or Y coordinate
indicates lack of motion in that direction. Thus, a value of (0,-1) for (X, Y) indicates motion
straight up, a value of (-1, 0) indicates motion to the left, and (1, 1) indicates motion that is
simultaneously downward and to the right.
In this project, you will need to design five classes, namely Shape, ComplexShape, SimpleShape,
Box and Tent. These classes form the inheritance hierarchy as showing in the following figure.
Shape
ComplexShape
SimpleShape
Box
Tent
Figure 1
1
Section 3.1: Classes Description
The Shape class has a move() function that is pure virtual. This is because a shape is moved by
erasing it at its current position and redrawing it at new position and it is not possible to know
how to draw a shape without knowing what type of shape it is.
The SimpleShape class represents objects that can be drawn at a given position in a specified
color. Accordingly, it has member variables for representing position and color and member
functions for setting and accessing those values. The SimpleShape class inherits from Shape,
notice that the SimpleShape class is still abstract because if provides no implementation for the
draw() method. The class does implement the move() method, though. The is because the move()
method works the same way for all subclasses of SimpleShape: erase the shape at its current
position, compute its new position, and draw the shape at the new position. The draw() method,
however, works differently for each concrete subclass that implements it. Because draw() is
virtual, the move() method will always call the appropriate version of draw(), even when the call
to draw() is through a pointer to the abstract class Shape.
The Box and Tent classes are the concrete classes at the tip of the inheritance hierarchy. They
define a specific concrete shape and implement the member function draw() that draws the shape
at its current position using the shape’s specified color.
The Box class defines a rectangular shape by specifying the positon of its tope left-hand corner
together with its width and height. The Tent class defines a triangle with a horizontal base whose
two other sides are equal in length and whose height is half the length of the base. A Tent object
is specified by giving the position of the left end point of its base together with the length of the
base. For example, a tent whose base has length 5 would look like this:
*
* *
* * * *
The CompletShape class provides a mechanism for assembling a collection of simple shapes to
form a single shape that can be moved using a single command. The class maintains a vector of
pointers to Shape objects, and implements its move() method is by calling the move() methods of
all the Shape objects in its collections. Likewise, ComplexShape has a setDirection() method that
can be used to cause all of its constituent shapes to move in the same direction.
Program TestShape.cpp is the driver’s program which we will use to test all of above classes.
The program starts out by creating two simple shapes - a tent and a box. The tent is created at the
left edge of the screen while the box is near the right edge. The program moves the tent to the
right at the same time that it is moving the box to the left, stopping the motion when the two
shapes are within a few coordinates of each other. Line 27-39 create a complex shape out of the
two simple shapes, and then moves the complex shape diagonally downward and to the right.
Finally, the program moves the box horizontally to the right.
2
Section 3.2: UML Diagrams for Each Class
1. Shape class
Shape
-dRow : int -dCol : int
+setDirection(int, int ) : void +getDirection(int &, int &) : void +move() : void = 0
Member
Data Type
Description
Variable
dRow
int
This represents the direction of row motion.
dCol
int
This represents the direction of row motion.
Member Function
void setDirection(int drow, int dcol)
Function Description
This function should initialize all member variable by the initial value defined inside the UML.
This function need to be override later by inherited classes, i.e. it need to be declared virtual.
void getDirection(int &drow, int &dcol)
virtual void move() = 0
This function initializes member variable dRow, dCol with the input parameter.
This is a pure virtual function
2. SimpleShape class (inherited from Shape class)
A SimpleShape is drawn at a give position in a specified color
SimpleShape
-rowPos : int -ColPos : int -color : int
+getPosition(int &, int &) : void +setPosition(int, int ) : void +getColor() : int
+setColor(int ) : void +move() : void
Member
Data Type
Description
Variable
rowPos
int
This represents the X position of the shape that to be drawn.
colPos
int
This represents the Y position of the shape that to be drawn.
color
int
This represents the color of the shape
3
Member Function
Function Description
void getPosition(int &row, int &col)
void setPosition(int row, int col )
int getColor()
Void setColor(int c)
This function should initialize member variable rowPos & colPos with the input parameters.
This is the mutator for member variable rowPos & colPos.
This is the accessor for member variable color. This is the mutator for member variable color.
3. Box class (inherited from SimpleShape class)
A Box is a rectangular type of shape
Box
-width : int -height : int
+Box(int, int, int, int) +draw() : virtual void
Member Function
Box(int rowPos, int colPos, int width, int height)
virtual void draw()
Function Description
This is the constructor, it sets the color, position and dimensions for a box shape, and draws the
box at its initial position
This function draw the lines that make up the box (a rectangle shape of *
4. Tent class (inherited from SimpleShape class)
A Tent is an isosceles triangle whose horizontal base has a given length and whose height is half
the length of the base. The position of the triangle is the left end point of the base.
Tent
-baseLength : int
+Tent(int, int, int) +draw() : virtual void
Member Function
Tent(int baseRowPos, int baseColPos, int baseLength)
virtual void draw()
Function Description
This is the constructor, it sets the color for a Tent shape, sets the position of the tent as well as
the length of its base and draw it at its initial position.
This function draw the lines that make up the tent.
4
5. ComplexShape class (inherited from Shape class)
A ComplexShape is made up of simpler shapes. It is represented as a vector of pointers to the
simpler shapes that make it up.
ComplexShape
-shapes : vector
+ComplexShape(Shape **, int) +move() : virtual void
+setDirection(int, int) : virtual void
Member Function
ComplexShape(Shape ** shapeCollection, int shapesCount))
Virtual void move()
virtual void setDirection(int dRow, int dCol)
6. TestShape class
Function Description
This is the constructor, it builds a complex shape by assembling a vector of constituent shapes.
Moves a complex shape by moving the constituent shapes.
Sets the direction of a complex shape by setting the direction of all constituent shapes
This is the driver’s program used to test on the various Shape classes and subclasses and do the
graphic animation. TestShape class contains only main() function, within main() function, you’re
required to do the following:
Create a Tent object with initial row & column position at 11, 5 respectively. Also initialize its
base length to be 13.
Crate a Box object with initial row & column position at 5, 65 respectively. Also initialize its
width and height to be 4, 7 respectively.
Draw above created Tent and Box objects by calling their draw() function
Set above Tent object’s initial direction of motion, let it move horizontally to the right.
Set above Box object’s initial direction of motion, let it move horizontally to the left.
Simultaneously move the tent and the box. Note: this will make them move towards each other.
Create a complex shape composed of the tent and the box.
Set the direction for the complex shape and move the complex shape: this moves both the tent
and the box diagonally to the right.
Move the box by itself horizontally to the right.
5
Section 3.3: Miscellaneous Programming Requirements
You’re given the skeleton of three source codes, namely ShapeAnimator.h, ShapeAnimator.cpp
and TestShape.cpp.
For simplicity, please put all class declaration inside the ShapeAnimator.h file, i.e. put all classes
shown in Figure 1’s declaration inside this file.
ShapeAnimator.cpp will be the class definition file for ShapeAnimator.h
As we mentioned on pp.1, inside TestShape.cpp, within the main( ), we used certain functions
that are peculiar to Microsoft Windows OS that directly access the screen and manage the timer,
as we write the code by using a Windows machine. If you use *nix system, the same principle
applies, but you might need to change the code a little bit.
Section 4: Grading Rubric
correctly designed the ShapeAnimator.h file, each class definition is worth 4 pts [Total 16 pts]
correctly implements the ShapeAnimator.cpp file. Each function’s full definition is worth 4 pts
[Total 24 pts]
In TestShape.cpp, students correctly finished the all the codes [5 pts]
The program submitted compiles, runs, and produces the correct output [5 pts]
HERE ARE THE THREE CLASSES I DISCUSSED AT THE TOP:----------------------------------
---------------------------------------------------------------------------------------------------------------------
-------------------
--------------------------------------------------------------------------------------------------------------------
----------------------------------
--------------------------------------------------------------------------------------------------------------------
----------------------------------
ComplexShape
SimpleShape
Solution
//main.cpp
#include "ShapeAnimator.h"
int main()
{
// Create a tent and a box
Tent tent(20, 10, 13);
Box box( 5, 10, 4, 7);
// Draw the tent and the box
tent.draw();
box.draw();
// Set direction of motion for the two shapes
tent.setDirection(-1, 0); // Tent moves straight up
box.setDirection(0, 1); // Box moves horizontally to the right
// Simultaneously move the tent and the box
for (int k = 0; k < 12; k++)
{
Sleep(75);
tent.move();
box.move();
}
box.move(); tent.move();
// Move the box farther to the right
for (int k = 0; k < 48; k++)
{
Sleep(75);
box.move();
}
// Create a complex shape composed of the tent and the box
Shape *myShapes[] = {&tent, &box};
ComplexShape cS(myShapes, 2);
// Set directions for the two shapes
tent.setDirection(1, 0);
box.setDirection(0, -1);
// Move the complex shape: this moves both the tent and the box
for (int k = 0; k < 12; k++)
{
Sleep(75);
cS.move();
}
// Continue moving the box by itself
for (int k = 0; k < 36; k ++)
{
Sleep(75);
box.move();
}
return 0;
}
=====================================================================
=======
//ShapeAnimator.cpp
#include "ShapeAnimator.h"
void SimpleShape::move()
{
int dRow, dCol; // Direction of motion
int savedColor = color;
color = 0; // Drawing in color 0 erases the shape
draw();
// Compute the new postion for the shape by adding a step in
// the proper direction to the current position
getDirection(dRow, dCol);
rowPos += dRow;
colPos += dCol;
// Draw the shape at its new position in its specified color
color = savedColor;
draw();
}
//***********************************
// Draws a tent at its position *
//***********************************
void Tent:: draw() const
{
int rowPos, colPos;
COORD pos;
int currentLength = length;
// Set the color attribute
SetConsoleTextAttribute(outHandle, getColor());
getPosition(rowPos, colPos);
pos.Y = rowPos; pos.X = colPos;
// Draw the lines that form the tent beginning with
// the base and moving up toward the point
for (int r = 0; r < length/2; r++)
{
SetConsoleCursorPosition(outHandle,pos);
for (int k = 0; k < currentLength; k++)
{
cout << "*";
}
cout << endl;
pos.Y--;
pos.X ++;
currentLength -= 2;
}
// Restore normal attribute
SetConsoleTextAttribute(outHandle, 7);
}
//**********************************
// Draws a box shape *
//**********************************
void Box::draw() const
{
int rowPos, colPos;
COORD pos;
// Set the color attribute for the box
SetConsoleTextAttribute(outHandle, getColor());
getPosition(rowPos, colPos);
pos.X = colPos; pos.Y = rowPos;
// Draw the lines that make up the box
for (int r = 0; r < height; r++)
{
SetConsoleCursorPosition(outHandle, pos);
for (int c = 0; c < width; c++)
{
cout << "*";
}
cout << endl;
pos.Y++;
}
// Restore normal text attribute
SetConsoleTextAttribute(outHandle, 7);
}
//***********************************************
// Constructor sets the color, position, and *
// dimensions for a box shape, and draws *
// the box at its initial position *
//***********************************************
Box::Box(int rowPos, int colPos, int width, int height)
{
setColor(4);
setPosition(rowPos, colPos);
this->width = width;
this->height = height;
draw();
}
//***********************************************
// Constructor sets the color for a Tent shape, *
// sets the position of the tent as well as the *
// length of its base and draws it at its *
// initial position *
//***********************************************
Tent::Tent(int baseRowPos, int baseColPos, int length)
{
setColor(2);
setPosition(baseRowPos, baseColPos);
this->length = length;
draw();
}
//*********************************************************************
// Constructor builds a complex shape by assembling a vector of *
// constituent shapes *
//*********************************************************************
ComplexShape::ComplexShape(Shape ** shapeCollection, int shapesCount)
{
Shape *p;
for (int k = 0; k < shapesCount; k++)
{
p = shapeCollection[k];
shapes.push_back(p);
}
}
//**************************************
// Moves a complex shape by moving the *
// constituent shapes *
//**************************************
void ComplexShape::move()
{
for (int k = 0; k < shapes.size(); k++)
shapes[k]->move();
}
=====================================================================
========
//ShapeAnimator.h
#include
#include
#include
#include
using namespace std;
const HANDLE outHandle = GetStdHandle(STD_OUTPUT_HANDLE);
// A shape has a direction and is able to move in that direction.
// The move is a virtual member function.
class Shape
{
public:
void setDirection(int drow, int dcol)
{dRow = drow; dCol = dcol;}
void getDirection(int &drow, int &dcol) const
{drow = dRow; dcol = dCol;}
virtual void move()= 0;
private:
int dCol, dRow; // Direction of motion
};
// A SimpleShape can be drawn at a given position in a specified color
class SimpleShape : public Shape
{
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;
};
// A Box is a rectangular type of shape
class Box : public SimpleShape
{
public:
virtual void draw() const;
Box(int rowPos, int colPos, int width, int height);
private:
int width, height;
};
// A Tent is an isosceles triangle whose horizontal base has a
// given length and whose height is half the length of the base.
// The position of the triangle is the left endpoint of the base
class Tent : public SimpleShape
{
public:
virtual void draw() const;
Tent(int baseRowPos, int baseColPos, int length);
private:
int length;
};
// A ComplexShape is made up of simpler shapes. It is represented
// as a vector of pointers to the simpler shapes that make it up
class ComplexShape : public Shape
{
public:
ComplexShape(Shape ** shapeCollection, int shapesCount);
virtual void move();
private:
vector shapes;
};
=====================================================================
=

More Related Content

Similar to Please make the complete program, Distinguish between header files a.pdf

CPP homework help
CPP homework helpCPP homework help
CPP homework help
C++ Homework Help
 
Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdf
MemeMiner
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica
Miles Ford
 
OOP Assignment 03.pdf
OOP Assignment 03.pdfOOP Assignment 03.pdf
OOP Assignment 03.pdf
ARSLANMEHMOOD47
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
Conint29
 
Excel Tutorials - Random Value Selection from a List
Excel Tutorials - Random Value Selection from a ListExcel Tutorials - Random Value Selection from a List
Excel Tutorials - Random Value Selection from a List
Merve Nur Taş
 
A graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolationA graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolation
graphitech
 
Shoot-for-A-Star
Shoot-for-A-StarShoot-for-A-Star
Shoot-for-A-Star
Dmitry Kazakov
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
Abhishek Tirkey
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
GauravPandey43518
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
srijavel
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02
auswhit
 
Auto cad manual
Auto cad manualAuto cad manual
Auto cad manual
Jotham Gadot
 
Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3
JenniferBall44
 
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docxCMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
mary772
 
ENGR 102B Microsoft Excel Proficiency LevelsPlease have your in.docx
ENGR 102B Microsoft Excel Proficiency LevelsPlease have your in.docxENGR 102B Microsoft Excel Proficiency LevelsPlease have your in.docx
ENGR 102B Microsoft Excel Proficiency LevelsPlease have your in.docx
YASHU40
 
A graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolationA graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolation
graphitech
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classe
mecklenburgstrelitzh
 
E4
E4E4
E4
lksoo
 
Practical ActivitiesWeek06lab08-1.pngPractical Activities.docx
Practical ActivitiesWeek06lab08-1.pngPractical Activities.docxPractical ActivitiesWeek06lab08-1.pngPractical Activities.docx
Practical ActivitiesWeek06lab08-1.pngPractical Activities.docx
ChantellPantoja184
 

Similar to Please make the complete program, Distinguish between header files a.pdf (20)

CPP homework help
CPP homework helpCPP homework help
CPP homework help
 
Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdf
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica
 
OOP Assignment 03.pdf
OOP Assignment 03.pdfOOP Assignment 03.pdf
OOP Assignment 03.pdf
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
 
Excel Tutorials - Random Value Selection from a List
Excel Tutorials - Random Value Selection from a ListExcel Tutorials - Random Value Selection from a List
Excel Tutorials - Random Value Selection from a List
 
A graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolationA graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolation
 
Shoot-for-A-Star
Shoot-for-A-StarShoot-for-A-Star
Shoot-for-A-Star
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02
 
Auto cad manual
Auto cad manualAuto cad manual
Auto cad manual
 
Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3
 
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docxCMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
 
ENGR 102B Microsoft Excel Proficiency LevelsPlease have your in.docx
ENGR 102B Microsoft Excel Proficiency LevelsPlease have your in.docxENGR 102B Microsoft Excel Proficiency LevelsPlease have your in.docx
ENGR 102B Microsoft Excel Proficiency LevelsPlease have your in.docx
 
A graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolationA graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolation
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classe
 
E4
E4E4
E4
 
Practical ActivitiesWeek06lab08-1.pngPractical Activities.docx
Practical ActivitiesWeek06lab08-1.pngPractical Activities.docxPractical ActivitiesWeek06lab08-1.pngPractical Activities.docx
Practical ActivitiesWeek06lab08-1.pngPractical Activities.docx
 

More from SALES97

Blossom Corporation had 120,000 common shares outstanding on Decembe.pdf
Blossom Corporation had 120,000 common shares outstanding on Decembe.pdfBlossom Corporation had 120,000 common shares outstanding on Decembe.pdf
Blossom Corporation had 120,000 common shares outstanding on Decembe.pdf
SALES97
 
A system experiences a phase change from liquid to solid. Is this exo.pdf
A system experiences a phase change from liquid to solid. Is this exo.pdfA system experiences a phase change from liquid to solid. Is this exo.pdf
A system experiences a phase change from liquid to solid. Is this exo.pdf
SALES97
 
Write an equation of a tangent function with the following characters.pdf
Write an equation of a tangent function with the following characters.pdfWrite an equation of a tangent function with the following characters.pdf
Write an equation of a tangent function with the following characters.pdf
SALES97
 
Why is a mixture of alcohol and water used, rather than simply water.pdf
Why is a mixture of alcohol and water used, rather than simply water.pdfWhy is a mixture of alcohol and water used, rather than simply water.pdf
Why is a mixture of alcohol and water used, rather than simply water.pdf
SALES97
 
Why are the 1960s relatively turbulentSolutionAnswer1960s .pdf
Why are the 1960s relatively turbulentSolutionAnswer1960s .pdfWhy are the 1960s relatively turbulentSolutionAnswer1960s .pdf
Why are the 1960s relatively turbulentSolutionAnswer1960s .pdf
SALES97
 
When acting as a neurotransmitter NO binds to the iron atom in vario.pdf
When acting as a neurotransmitter NO binds to the iron atom in vario.pdfWhen acting as a neurotransmitter NO binds to the iron atom in vario.pdf
When acting as a neurotransmitter NO binds to the iron atom in vario.pdf
SALES97
 
Which of the following are reasons that Drosophila are an ideal exper.pdf
Which of the following are reasons that Drosophila are an ideal exper.pdfWhich of the following are reasons that Drosophila are an ideal exper.pdf
Which of the following are reasons that Drosophila are an ideal exper.pdf
SALES97
 
What Michael acceptor is needed for the conjugate addition Beta - .pdf
What Michael acceptor is needed for the conjugate addition  Beta - .pdfWhat Michael acceptor is needed for the conjugate addition  Beta - .pdf
What Michael acceptor is needed for the conjugate addition Beta - .pdf
SALES97
 
What is the role of intuition in decision-makingSolutionIntui.pdf
What is the role of intuition in decision-makingSolutionIntui.pdfWhat is the role of intuition in decision-makingSolutionIntui.pdf
What is the role of intuition in decision-makingSolutionIntui.pdf
SALES97
 
What is the difference between a HTML element’s id attribute and nam.pdf
What is the difference between a HTML element’s id attribute and nam.pdfWhat is the difference between a HTML element’s id attribute and nam.pdf
What is the difference between a HTML element’s id attribute and nam.pdf
SALES97
 
What happens when youre Running Scripts without a console in Linux.pdf
What happens when youre Running Scripts without a console in Linux.pdfWhat happens when youre Running Scripts without a console in Linux.pdf
What happens when youre Running Scripts without a console in Linux.pdf
SALES97
 
TrueFalse A virtual private network is a way to use the Internet to.pdf
TrueFalse  A virtual private network is a way to use the Internet to.pdfTrueFalse  A virtual private network is a way to use the Internet to.pdf
TrueFalse A virtual private network is a way to use the Internet to.pdf
SALES97
 
The total physical units accounted for is the sum of the units co.pdf
The total physical units accounted for is the sum of the units co.pdfThe total physical units accounted for is the sum of the units co.pdf
The total physical units accounted for is the sum of the units co.pdf
SALES97
 
The problem can be found below. I would like someone to run this. I .pdf
The problem can be found below. I would like someone to run this. I .pdfThe problem can be found below. I would like someone to run this. I .pdf
The problem can be found below. I would like someone to run this. I .pdf
SALES97
 
The probability that a teacher will give an unannounced test duri.pdf
The probability that a teacher will give an unannounced test duri.pdfThe probability that a teacher will give an unannounced test duri.pdf
The probability that a teacher will give an unannounced test duri.pdf
SALES97
 
The Orlando MedicalOrlando Medical Corporation financial statements.pdf
The Orlando MedicalOrlando Medical Corporation financial statements.pdfThe Orlando MedicalOrlando Medical Corporation financial statements.pdf
The Orlando MedicalOrlando Medical Corporation financial statements.pdf
SALES97
 
The IP network is a virtual network and must rely on a link layer ne.pdf
The IP network is a virtual network and must rely on a link layer ne.pdfThe IP network is a virtual network and must rely on a link layer ne.pdf
The IP network is a virtual network and must rely on a link layer ne.pdf
SALES97
 
Table 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdf
Table 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdfTable 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdf
Table 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdf
SALES97
 
State if you agree or disagree with the statement made and whyLes.pdf
State if you agree or disagree with the statement made and whyLes.pdfState if you agree or disagree with the statement made and whyLes.pdf
State if you agree or disagree with the statement made and whyLes.pdf
SALES97
 
subject.....project management.Tools and Processes Based on the pr.pdf
subject.....project management.Tools and Processes Based on the pr.pdfsubject.....project management.Tools and Processes Based on the pr.pdf
subject.....project management.Tools and Processes Based on the pr.pdf
SALES97
 

More from SALES97 (20)

Blossom Corporation had 120,000 common shares outstanding on Decembe.pdf
Blossom Corporation had 120,000 common shares outstanding on Decembe.pdfBlossom Corporation had 120,000 common shares outstanding on Decembe.pdf
Blossom Corporation had 120,000 common shares outstanding on Decembe.pdf
 
A system experiences a phase change from liquid to solid. Is this exo.pdf
A system experiences a phase change from liquid to solid. Is this exo.pdfA system experiences a phase change from liquid to solid. Is this exo.pdf
A system experiences a phase change from liquid to solid. Is this exo.pdf
 
Write an equation of a tangent function with the following characters.pdf
Write an equation of a tangent function with the following characters.pdfWrite an equation of a tangent function with the following characters.pdf
Write an equation of a tangent function with the following characters.pdf
 
Why is a mixture of alcohol and water used, rather than simply water.pdf
Why is a mixture of alcohol and water used, rather than simply water.pdfWhy is a mixture of alcohol and water used, rather than simply water.pdf
Why is a mixture of alcohol and water used, rather than simply water.pdf
 
Why are the 1960s relatively turbulentSolutionAnswer1960s .pdf
Why are the 1960s relatively turbulentSolutionAnswer1960s .pdfWhy are the 1960s relatively turbulentSolutionAnswer1960s .pdf
Why are the 1960s relatively turbulentSolutionAnswer1960s .pdf
 
When acting as a neurotransmitter NO binds to the iron atom in vario.pdf
When acting as a neurotransmitter NO binds to the iron atom in vario.pdfWhen acting as a neurotransmitter NO binds to the iron atom in vario.pdf
When acting as a neurotransmitter NO binds to the iron atom in vario.pdf
 
Which of the following are reasons that Drosophila are an ideal exper.pdf
Which of the following are reasons that Drosophila are an ideal exper.pdfWhich of the following are reasons that Drosophila are an ideal exper.pdf
Which of the following are reasons that Drosophila are an ideal exper.pdf
 
What Michael acceptor is needed for the conjugate addition Beta - .pdf
What Michael acceptor is needed for the conjugate addition  Beta - .pdfWhat Michael acceptor is needed for the conjugate addition  Beta - .pdf
What Michael acceptor is needed for the conjugate addition Beta - .pdf
 
What is the role of intuition in decision-makingSolutionIntui.pdf
What is the role of intuition in decision-makingSolutionIntui.pdfWhat is the role of intuition in decision-makingSolutionIntui.pdf
What is the role of intuition in decision-makingSolutionIntui.pdf
 
What is the difference between a HTML element’s id attribute and nam.pdf
What is the difference between a HTML element’s id attribute and nam.pdfWhat is the difference between a HTML element’s id attribute and nam.pdf
What is the difference between a HTML element’s id attribute and nam.pdf
 
What happens when youre Running Scripts without a console in Linux.pdf
What happens when youre Running Scripts without a console in Linux.pdfWhat happens when youre Running Scripts without a console in Linux.pdf
What happens when youre Running Scripts without a console in Linux.pdf
 
TrueFalse A virtual private network is a way to use the Internet to.pdf
TrueFalse  A virtual private network is a way to use the Internet to.pdfTrueFalse  A virtual private network is a way to use the Internet to.pdf
TrueFalse A virtual private network is a way to use the Internet to.pdf
 
The total physical units accounted for is the sum of the units co.pdf
The total physical units accounted for is the sum of the units co.pdfThe total physical units accounted for is the sum of the units co.pdf
The total physical units accounted for is the sum of the units co.pdf
 
The problem can be found below. I would like someone to run this. I .pdf
The problem can be found below. I would like someone to run this. I .pdfThe problem can be found below. I would like someone to run this. I .pdf
The problem can be found below. I would like someone to run this. I .pdf
 
The probability that a teacher will give an unannounced test duri.pdf
The probability that a teacher will give an unannounced test duri.pdfThe probability that a teacher will give an unannounced test duri.pdf
The probability that a teacher will give an unannounced test duri.pdf
 
The Orlando MedicalOrlando Medical Corporation financial statements.pdf
The Orlando MedicalOrlando Medical Corporation financial statements.pdfThe Orlando MedicalOrlando Medical Corporation financial statements.pdf
The Orlando MedicalOrlando Medical Corporation financial statements.pdf
 
The IP network is a virtual network and must rely on a link layer ne.pdf
The IP network is a virtual network and must rely on a link layer ne.pdfThe IP network is a virtual network and must rely on a link layer ne.pdf
The IP network is a virtual network and must rely on a link layer ne.pdf
 
Table 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdf
Table 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdfTable 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdf
Table 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdf
 
State if you agree or disagree with the statement made and whyLes.pdf
State if you agree or disagree with the statement made and whyLes.pdfState if you agree or disagree with the statement made and whyLes.pdf
State if you agree or disagree with the statement made and whyLes.pdf
 
subject.....project management.Tools and Processes Based on the pr.pdf
subject.....project management.Tools and Processes Based on the pr.pdfsubject.....project management.Tools and Processes Based on the pr.pdf
subject.....project management.Tools and Processes Based on the pr.pdf
 

Recently uploaded

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 

Recently uploaded (20)

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 

Please make the complete program, Distinguish between header files a.pdf

  • 1. Please make the complete program, Distinguish between header files and class files. I give three of the classes below, but I do not know if they are complete.I already posted this question before, but the answer was incorreect. ask any questions if you need any help. --------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------- ----------------------------------- Section 1: Project Objectives By given a class hierarchy, focus on Object-Oriented-Design concept, design and write multiple classes. Be able to apply the concepts of inheritance, polymorphism, abstract classes, pure virtual functions, function overriding, etc. Be familiar with common functions in vector class in C++. Section 2: Background Introduction Video game programmers often have to maintain a collection of figures that are simultaneously moving in various directions on the screen. In this project, we will design a solution to a simplified version of the problem. We will maintain a collection of geometric shapes and simultaneously animate those shapes. The functions used to directly access the screen and manage the timer are peculiar to Microsoft Windows, but the principles used are very general and are applicable to all operating systems. Section 3: Project Description We begin with a class that represents a shape that is able to move in any of eight different directions, with each direction being specified by a pair of integer (X, Y) coordinates. Upward or downward motion is indicated by a Y component of ±1. A value of 0 for an X or Y coordinate indicates lack of motion in that direction. Thus, a value of (0,-1) for (X, Y) indicates motion straight up, a value of (-1, 0) indicates motion to the left, and (1, 1) indicates motion that is simultaneously downward and to the right. In this project, you will need to design five classes, namely Shape, ComplexShape, SimpleShape, Box and Tent. These classes form the inheritance hierarchy as showing in the following figure. Shape ComplexShape SimpleShape Box Tent Figure 1 1
  • 2. Section 3.1: Classes Description The Shape class has a move() function that is pure virtual. This is because a shape is moved by erasing it at its current position and redrawing it at new position and it is not possible to know how to draw a shape without knowing what type of shape it is. The SimpleShape class represents objects that can be drawn at a given position in a specified color. Accordingly, it has member variables for representing position and color and member functions for setting and accessing those values. The SimpleShape class inherits from Shape, notice that the SimpleShape class is still abstract because if provides no implementation for the draw() method. The class does implement the move() method, though. The is because the move() method works the same way for all subclasses of SimpleShape: erase the shape at its current position, compute its new position, and draw the shape at the new position. The draw() method, however, works differently for each concrete subclass that implements it. Because draw() is virtual, the move() method will always call the appropriate version of draw(), even when the call to draw() is through a pointer to the abstract class Shape. The Box and Tent classes are the concrete classes at the tip of the inheritance hierarchy. They define a specific concrete shape and implement the member function draw() that draws the shape at its current position using the shape’s specified color. The Box class defines a rectangular shape by specifying the positon of its tope left-hand corner together with its width and height. The Tent class defines a triangle with a horizontal base whose two other sides are equal in length and whose height is half the length of the base. A Tent object is specified by giving the position of the left end point of its base together with the length of the base. For example, a tent whose base has length 5 would look like this: * * * * * * * The CompletShape class provides a mechanism for assembling a collection of simple shapes to form a single shape that can be moved using a single command. The class maintains a vector of pointers to Shape objects, and implements its move() method is by calling the move() methods of all the Shape objects in its collections. Likewise, ComplexShape has a setDirection() method that can be used to cause all of its constituent shapes to move in the same direction. Program TestShape.cpp is the driver’s program which we will use to test all of above classes. The program starts out by creating two simple shapes - a tent and a box. The tent is created at the left edge of the screen while the box is near the right edge. The program moves the tent to the right at the same time that it is moving the box to the left, stopping the motion when the two shapes are within a few coordinates of each other. Line 27-39 create a complex shape out of the two simple shapes, and then moves the complex shape diagonally downward and to the right.
  • 3. Finally, the program moves the box horizontally to the right. 2 Section 3.2: UML Diagrams for Each Class 1. Shape class Shape -dRow : int -dCol : int +setDirection(int, int ) : void +getDirection(int &, int &) : void +move() : void = 0 Member Data Type Description Variable dRow int This represents the direction of row motion. dCol int This represents the direction of row motion. Member Function void setDirection(int drow, int dcol) Function Description This function should initialize all member variable by the initial value defined inside the UML. This function need to be override later by inherited classes, i.e. it need to be declared virtual. void getDirection(int &drow, int &dcol) virtual void move() = 0 This function initializes member variable dRow, dCol with the input parameter. This is a pure virtual function 2. SimpleShape class (inherited from Shape class) A SimpleShape is drawn at a give position in a specified color SimpleShape -rowPos : int -ColPos : int -color : int +getPosition(int &, int &) : void +setPosition(int, int ) : void +getColor() : int +setColor(int ) : void +move() : void Member Data Type Description Variable
  • 4. rowPos int This represents the X position of the shape that to be drawn. colPos int This represents the Y position of the shape that to be drawn. color int This represents the color of the shape 3 Member Function Function Description void getPosition(int &row, int &col) void setPosition(int row, int col ) int getColor() Void setColor(int c) This function should initialize member variable rowPos & colPos with the input parameters. This is the mutator for member variable rowPos & colPos. This is the accessor for member variable color. This is the mutator for member variable color. 3. Box class (inherited from SimpleShape class) A Box is a rectangular type of shape Box -width : int -height : int +Box(int, int, int, int) +draw() : virtual void Member Function Box(int rowPos, int colPos, int width, int height) virtual void draw() Function Description This is the constructor, it sets the color, position and dimensions for a box shape, and draws the box at its initial position This function draw the lines that make up the box (a rectangle shape of * 4. Tent class (inherited from SimpleShape class) A Tent is an isosceles triangle whose horizontal base has a given length and whose height is half the length of the base. The position of the triangle is the left end point of the base. Tent
  • 5. -baseLength : int +Tent(int, int, int) +draw() : virtual void Member Function Tent(int baseRowPos, int baseColPos, int baseLength) virtual void draw() Function Description This is the constructor, it sets the color for a Tent shape, sets the position of the tent as well as the length of its base and draw it at its initial position. This function draw the lines that make up the tent. 4 5. ComplexShape class (inherited from Shape class) A ComplexShape is made up of simpler shapes. It is represented as a vector of pointers to the simpler shapes that make it up. ComplexShape -shapes : vector +ComplexShape(Shape **, int) +move() : virtual void +setDirection(int, int) : virtual void Member Function ComplexShape(Shape ** shapeCollection, int shapesCount)) Virtual void move() virtual void setDirection(int dRow, int dCol) 6. TestShape class Function Description This is the constructor, it builds a complex shape by assembling a vector of constituent shapes. Moves a complex shape by moving the constituent shapes. Sets the direction of a complex shape by setting the direction of all constituent shapes This is the driver’s program used to test on the various Shape classes and subclasses and do the graphic animation. TestShape class contains only main() function, within main() function, you’re required to do the following: Create a Tent object with initial row & column position at 11, 5 respectively. Also initialize its base length to be 13. Crate a Box object with initial row & column position at 5, 65 respectively. Also initialize its width and height to be 4, 7 respectively. Draw above created Tent and Box objects by calling their draw() function
  • 6. Set above Tent object’s initial direction of motion, let it move horizontally to the right. Set above Box object’s initial direction of motion, let it move horizontally to the left. Simultaneously move the tent and the box. Note: this will make them move towards each other. Create a complex shape composed of the tent and the box. Set the direction for the complex shape and move the complex shape: this moves both the tent and the box diagonally to the right. Move the box by itself horizontally to the right. 5 Section 3.3: Miscellaneous Programming Requirements You’re given the skeleton of three source codes, namely ShapeAnimator.h, ShapeAnimator.cpp and TestShape.cpp. For simplicity, please put all class declaration inside the ShapeAnimator.h file, i.e. put all classes shown in Figure 1’s declaration inside this file. ShapeAnimator.cpp will be the class definition file for ShapeAnimator.h As we mentioned on pp.1, inside TestShape.cpp, within the main( ), we used certain functions that are peculiar to Microsoft Windows OS that directly access the screen and manage the timer, as we write the code by using a Windows machine. If you use *nix system, the same principle applies, but you might need to change the code a little bit. Section 4: Grading Rubric correctly designed the ShapeAnimator.h file, each class definition is worth 4 pts [Total 16 pts] correctly implements the ShapeAnimator.cpp file. Each function’s full definition is worth 4 pts [Total 24 pts] In TestShape.cpp, students correctly finished the all the codes [5 pts] The program submitted compiles, runs, and produces the correct output [5 pts] HERE ARE THE THREE CLASSES I DISCUSSED AT THE TOP:---------------------------------- --------------------------------------------------------------------------------------------------------------------- ------------------- -------------------------------------------------------------------------------------------------------------------- ---------------------------------- -------------------------------------------------------------------------------------------------------------------- ---------------------------------- ComplexShape SimpleShape Solution
  • 7. //main.cpp #include "ShapeAnimator.h" int main() { // Create a tent and a box Tent tent(20, 10, 13); Box box( 5, 10, 4, 7); // Draw the tent and the box tent.draw(); box.draw(); // Set direction of motion for the two shapes tent.setDirection(-1, 0); // Tent moves straight up box.setDirection(0, 1); // Box moves horizontally to the right // Simultaneously move the tent and the box for (int k = 0; k < 12; k++) { Sleep(75); tent.move(); box.move(); } box.move(); tent.move(); // Move the box farther to the right for (int k = 0; k < 48; k++) { Sleep(75); box.move(); } // Create a complex shape composed of the tent and the box Shape *myShapes[] = {&tent, &box}; ComplexShape cS(myShapes, 2); // Set directions for the two shapes tent.setDirection(1, 0); box.setDirection(0, -1); // Move the complex shape: this moves both the tent and the box for (int k = 0; k < 12; k++) {
  • 8. Sleep(75); cS.move(); } // Continue moving the box by itself for (int k = 0; k < 36; k ++) { Sleep(75); box.move(); } return 0; } ===================================================================== ======= //ShapeAnimator.cpp #include "ShapeAnimator.h" void SimpleShape::move() { int dRow, dCol; // Direction of motion int savedColor = color; color = 0; // Drawing in color 0 erases the shape draw(); // Compute the new postion for the shape by adding a step in // the proper direction to the current position getDirection(dRow, dCol); rowPos += dRow; colPos += dCol; // Draw the shape at its new position in its specified color color = savedColor; draw(); } //*********************************** // Draws a tent at its position * //*********************************** void Tent:: draw() const {
  • 9. int rowPos, colPos; COORD pos; int currentLength = length; // Set the color attribute SetConsoleTextAttribute(outHandle, getColor()); getPosition(rowPos, colPos); pos.Y = rowPos; pos.X = colPos; // Draw the lines that form the tent beginning with // the base and moving up toward the point for (int r = 0; r < length/2; r++) { SetConsoleCursorPosition(outHandle,pos); for (int k = 0; k < currentLength; k++) { cout << "*"; } cout << endl; pos.Y--; pos.X ++; currentLength -= 2; } // Restore normal attribute SetConsoleTextAttribute(outHandle, 7); } //********************************** // Draws a box shape * //********************************** void Box::draw() const { int rowPos, colPos; COORD pos; // Set the color attribute for the box SetConsoleTextAttribute(outHandle, getColor()); getPosition(rowPos, colPos); pos.X = colPos; pos.Y = rowPos; // Draw the lines that make up the box
  • 10. for (int r = 0; r < height; r++) { SetConsoleCursorPosition(outHandle, pos); for (int c = 0; c < width; c++) { cout << "*"; } cout << endl; pos.Y++; } // Restore normal text attribute SetConsoleTextAttribute(outHandle, 7); } //*********************************************** // Constructor sets the color, position, and * // dimensions for a box shape, and draws * // the box at its initial position * //*********************************************** Box::Box(int rowPos, int colPos, int width, int height) { setColor(4); setPosition(rowPos, colPos); this->width = width; this->height = height; draw(); } //*********************************************** // Constructor sets the color for a Tent shape, * // sets the position of the tent as well as the * // length of its base and draws it at its * // initial position * //*********************************************** Tent::Tent(int baseRowPos, int baseColPos, int length) { setColor(2); setPosition(baseRowPos, baseColPos);
  • 11. this->length = length; draw(); } //********************************************************************* // Constructor builds a complex shape by assembling a vector of * // constituent shapes * //********************************************************************* ComplexShape::ComplexShape(Shape ** shapeCollection, int shapesCount) { Shape *p; for (int k = 0; k < shapesCount; k++) { p = shapeCollection[k]; shapes.push_back(p); } } //************************************** // Moves a complex shape by moving the * // constituent shapes * //************************************** void ComplexShape::move() { for (int k = 0; k < shapes.size(); k++) shapes[k]->move(); } ===================================================================== ======== //ShapeAnimator.h #include #include #include #include using namespace std; const HANDLE outHandle = GetStdHandle(STD_OUTPUT_HANDLE); // A shape has a direction and is able to move in that direction. // The move is a virtual member function.
  • 12. class Shape { public: void setDirection(int drow, int dcol) {dRow = drow; dCol = dcol;} void getDirection(int &drow, int &dcol) const {drow = dRow; dcol = dCol;} virtual void move()= 0; private: int dCol, dRow; // Direction of motion }; // A SimpleShape can be drawn at a given position in a specified color class SimpleShape : public Shape { 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; }; // A Box is a rectangular type of shape class Box : public SimpleShape { public: virtual void draw() const;
  • 13. Box(int rowPos, int colPos, int width, int height); private: int width, height; }; // A Tent is an isosceles triangle whose horizontal base has a // given length and whose height is half the length of the base. // The position of the triangle is the left endpoint of the base class Tent : public SimpleShape { public: virtual void draw() const; Tent(int baseRowPos, int baseColPos, int length); private: int length; }; // A ComplexShape is made up of simpler shapes. It is represented // as a vector of pointers to the simpler shapes that make it up class ComplexShape : public Shape { public: ComplexShape(Shape ** shapeCollection, int shapesCount); virtual void move(); private: vector shapes; }; ===================================================================== =