Question: Question 1 : Base and Utility Classes Define two base classes: GameEntity: An enumeration enum GameEntityType representing the various objects in the game: ExplosionType, MineType,
Question : Base and Utility Classes
Define two base classes:
GameEntity:
An enumeration enum GameEntityType representing the various objects in the game: ExplosionType, MineType, NoneType, ShipType. Note that the enumeration order is important.
Data Members:
std::tuple position representing the position of the entityGameEntityType type representing the type of the entity
Member Functions:
Constructor GameEntityint x int y char typestd::tuple getPos: Returns the position of the entity.GameEntityType getType: Returns the type of the entity.
Effect:
Member Functions:
virtual void applyGameEntity& entity: Accepts a GameEntity object as input and applies the effect to the entity. This function is pure virtual and needs to be implemented in derived classes.
Define a class Utils with the following static functions:
std::tuple generateRandomPosint gridWidth, int gridHeight: Returns a random position within a grid represented by gridWidth and gridHeight as a std::tuple.
double calculateDistancestd::tuple pos std::tuple pos: Returns the Euclidean distance between two positions given as pos and pos as a double.
In maincpp generate some random positions and calculate distances between them.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
