diff --git a/Alien-Invasion.vcxproj b/Alien-Invasion.vcxproj index 07b23f0..c0f837d 100644 --- a/Alien-Invasion.vcxproj +++ b/Alien-Invasion.vcxproj @@ -20,6 +20,7 @@ + @@ -32,11 +33,14 @@ - + - + + + + 17.0 diff --git a/Alien-Invasion.vcxproj.filters b/Alien-Invasion.vcxproj.filters index cb0c941..518a036 100644 --- a/Alien-Invasion.vcxproj.filters +++ b/Alien-Invasion.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -7,6 +7,9 @@ {d6265d0d-9e06-4a0b-9c88-39e5e3415fa3} + + {8a245181-84c7-4cb6-9cc0-a558bcaf50e4} + @@ -39,13 +42,13 @@ UnitsClasses - + UnitsClasses UnitsClasses - + UnitsClasses @@ -56,7 +59,19 @@ - + + ArmyClasses + + + ArmyClasses + + + ArmyClasses + + + + + UnitsClasses diff --git a/ArmyClasses/AlienArmy.h b/ArmyClasses/AlienArmy.h new file mode 100644 index 0000000..0385dac --- /dev/null +++ b/ArmyClasses/AlienArmy.h @@ -0,0 +1,20 @@ +#ifndef ALIEN_ARMY_H +#define ALIEN_ARMY_H + +#include "Army.h" +#include "..\Containers\LinkedQueue.h" +#include "..\Containers\ArrayStack.h" +#include "..\Containers\Deque.h" +#include "..\UnitClasses\Unit.h" +#include "..\UnitClasses\AlienSoldier.h" +#include "..\UnitClasses\AlienMonster.h" +#include "..\UnitClasses\AlienDrone.h" + +class AlienArmy: public Army +{ + LinkedQueue soliders; + // Array monsters; + Deque drones; +}; + +#endif \ No newline at end of file diff --git a/ArmyClasses/Army.h b/ArmyClasses/Army.h new file mode 100644 index 0000000..de2396e --- /dev/null +++ b/ArmyClasses/Army.h @@ -0,0 +1,14 @@ +#ifndef ARMY_H +#define ARMY_H + +class Army +{ +public: + virtual void addUnit() = 0; // Will take a pointer to Unit as a parameter + virtual void removeUnit() = 0; + virtual void print() const = 0; + virtual void attack() = 0; +}; + +#endif + diff --git a/ArmyClasses/EarthArmy.h b/ArmyClasses/EarthArmy.h new file mode 100644 index 0000000..18be8d2 --- /dev/null +++ b/ArmyClasses/EarthArmy.h @@ -0,0 +1,21 @@ +#ifndef EARTH_ARMY_H +#define EARTH_ARMY_H + +#include "Army.h" +#include "..\UnitClasses\Unit.h" +#include "..\Containers\ArrayStack.h" +#include "..\Containers\LinkedQueue.h" +#include "..\Containers\PriorityQueue.h" +#include "..\UnitClasses\Unit.h" +#include "..\UnitClasses\EarthSoldier.h" +#include "..\UnitClasses\EarthTank.h" +#include "..\UnitClasses\EarthGunnery.h" + +class EarthArmy: public Army +{ + LinkedQueue soldiers; + ArrayStack tanks; + PriorityQueue gunneries; +}; + +#endif diff --git a/Containers/ArrayStack.h b/Containers/ArrayStack.h index cfec059..9cea6f4 100644 --- a/Containers/ArrayStack.h +++ b/Containers/ArrayStack.h @@ -1,12 +1,12 @@ -#ifndef ARRAYSTACK_H -#define ARRAYSTACK_H +#ifndef ARRAY_STACK_H +#define ARRAY_STACK_H #include #include "StackADT.h" -// The default size is 100 +// The default size is 1000 template -class ArrayStack : public StackADT +class ArrayStack: public StackADT { enum { MAX_SIZE = 1000 }; private: @@ -22,11 +22,10 @@ class ArrayStack : public StackADT void printList() const; int getCount() const; }; -#endif template -inline ArrayStack::ArrayStack() : top(-1) -{} +inline ArrayStack::ArrayStack(): top(-1) +{ } template inline bool ArrayStack::isEmpty() const @@ -79,4 +78,4 @@ inline int ArrayStack::getCount() const return top + 1; } - +#endif diff --git a/Containers/Deque.h b/Containers/Deque.h index 2fea2f7..954f4dc 100644 --- a/Containers/Deque.h +++ b/Containers/Deque.h @@ -1,10 +1,10 @@ -#ifndef DEQUE_ -#define DEQUE_ +#ifndef DEQUE_H +#define DEQUE_H #include "LinkedQueue.h" template -class Deque : public LinkedQueue +class Deque: public LinkedQueue { public: bool dequeueBack(T& backEntry); @@ -12,7 +12,7 @@ class Deque : public LinkedQueue }; template -bool Deque::dequeueBack(T& backEntry) +inline bool Deque::dequeueBack(T& backEntry) { if (LinkedQueue ::isEmpty()) return false; diff --git a/Containers/LinkedQueue.h b/Containers/LinkedQueue.h index b87ea38..37649ba 100644 --- a/Containers/LinkedQueue.h +++ b/Containers/LinkedQueue.h @@ -1,12 +1,12 @@ -#ifndef LINKED_QUEUE_ -#define LINKED_QUEUE_ +#ifndef LINKED_QUEUE_H +#define LINKED_QUEUE_H #include #include "Node.h" #include "QueueADT.h" template -class LinkedQueue :public QueueADT +class LinkedQueue: public QueueADT { protected: Node* backPtr; @@ -24,17 +24,17 @@ class LinkedQueue :public QueueADT }; template -LinkedQueue::LinkedQueue():itemCount(0), backPtr(nullptr), frontPtr(nullptr) -{} +inline LinkedQueue::LinkedQueue():itemCount(0), backPtr(nullptr), frontPtr(nullptr) +{ } template -bool LinkedQueue::isEmpty() const +inline bool LinkedQueue::isEmpty() const { return (frontPtr == nullptr); } template -bool LinkedQueue::enqueue(const T& newEntry) +inline bool LinkedQueue::enqueue(const T& newEntry) { Node* newNodePtr = new Node(newEntry); // Insert the new node @@ -52,7 +52,7 @@ bool LinkedQueue::enqueue(const T& newEntry) } template -bool LinkedQueue::dequeue(T& frontEntry) +inline bool LinkedQueue::dequeue(T& frontEntry) { if (isEmpty()) return false; @@ -74,7 +74,7 @@ bool LinkedQueue::dequeue(T& frontEntry) } template -bool LinkedQueue::peek(T& frontEntry) const +inline bool LinkedQueue::peek(T& frontEntry) const { if (isEmpty()) return false; @@ -106,7 +106,7 @@ inline int LinkedQueue::getCount() const } template -LinkedQueue::~LinkedQueue() +inline LinkedQueue::~LinkedQueue() { T temp; while (dequeue(temp)); diff --git a/Containers/Node.h b/Containers/Node.h index b4d80ca..2c19301 100644 --- a/Containers/Node.h +++ b/Containers/Node.h @@ -1,5 +1,5 @@ -#ifndef _NODE -#define _NODE +#ifndef NODE_H +#define NODE_H template class Node @@ -19,33 +19,32 @@ class Node T getItem() const; Node* getPrev() const; Node* getNext() const; -}; // end Node -#endif +}; template < typename T> -Node::Node() +inline Node::Node() : prev(nullptr), next(nullptr) { } template < typename T> -Node::Node(const T& item) +inline Node::Node(const T& item) : item(item), prev(nullptr), next(nullptr) { } template < typename T> -Node::Node(const T& item, Node* prevNodePtr, Node* nextNodePtr) +inline Node::Node(const T& item, Node* prevNodePtr, Node* nextNodePtr) : item(item), prev(prevNodePtr), next(nextNodePtr) { } template < typename T> -void Node::setItem(const T& item) +inline void Node::setItem(const T& item) { this->item = item; } template < typename T> -void Node::setNext(Node* nextNodePtr) +inline void Node::setNext(Node* nextNodePtr) { next = nextNodePtr; } @@ -58,19 +57,21 @@ inline void Node::setPrev(Node* prevNodePtr) template < typename T> -T Node::getItem() const +inline T Node::getItem() const { return item; } template -Node* Node::getPrev() const +inline Node* Node::getPrev() const { return prev; } template < typename T> -Node* Node::getNext() const +inline Node* Node::getNext() const { return next; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Containers/PriorityNode.h b/Containers/PriorityNode.h index ac699bb..b11f4e4 100644 --- a/Containers/PriorityNode.h +++ b/Containers/PriorityNode.h @@ -1,5 +1,5 @@ -#ifndef PRIORITYNODE_H -#define PRIORITYNODE_H +#ifndef PRIORITY_NODE_H +#define PRIORITY_NODE_H template class PriorityNode @@ -13,22 +13,21 @@ class PriorityNode void setItem(const T& _item, int _priority); void setNext(PriorityNode* nextNodePtr); - + T getItem(int& _priority) const; PriorityNode* getNext() const; int getPriority() const; }; -#endif template -PriorityNode::PriorityNode(const T& _item, int _priority) +inline PriorityNode::PriorityNode(const T& _item, int _priority) { setItem(_item, _priority); next = nullptr; } template -void PriorityNode::setItem(const T& _item, int _priority) +inline void PriorityNode::setItem(const T& _item, int _priority) { item = _item; priority = _priority; @@ -41,7 +40,7 @@ void PriorityNode::setNext(PriorityNode* nextNodePtr) } template -T PriorityNode::getItem(int& _priority) const +inline T PriorityNode::getItem(int& _priority) const { _priority = priority; @@ -49,13 +48,15 @@ T PriorityNode::getItem(int& _priority) const } template -PriorityNode* PriorityNode::getNext() const +inline PriorityNode* PriorityNode::getNext() const { return next; } template -int PriorityNode::getPriority() const +inline int PriorityNode::getPriority() const { return priority; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Containers/PriorityQueue.h b/Containers/PriorityQueue.h index cb464e7..aac5ac2 100644 --- a/Containers/PriorityQueue.h +++ b/Containers/PriorityQueue.h @@ -1,5 +1,5 @@ -#ifndef PRIORITYQUEUE_H -#define PRIORITYQUEUE_H +#ifndef PRIORITY_QUEUE_H +#define PRIORITY_QUEUE_H #include #include "PriorityNode.h" @@ -25,16 +25,14 @@ class PriorityQueue ~PriorityQueue(); }; -#endif template -PriorityQueue::PriorityQueue(): head(nullptr), itemCount(0) -{ -} +inline PriorityQueue::PriorityQueue(): head(nullptr), itemCount(0) +{ } // Insert the new node in its correct position according to its priority template -void PriorityQueue::enqueue(const T& data, int priority) +inline void PriorityQueue::enqueue(const T& data, int priority) { PriorityNode* newNode = new PriorityNode(data, priority); @@ -55,7 +53,7 @@ void PriorityQueue::enqueue(const T& data, int priority) } template -bool PriorityQueue::dequeue(T& topEntry, int& pri) +inline bool PriorityQueue::dequeue(T& topEntry, int& pri) { if (isEmpty()) return false; @@ -70,7 +68,7 @@ bool PriorityQueue::dequeue(T& topEntry, int& pri) } template -bool PriorityQueue::peek(T& topEntry, int& priority) +inline bool PriorityQueue::peek(T& topEntry, int& priority) { if (isEmpty()) return false; @@ -82,20 +80,21 @@ bool PriorityQueue::peek(T& topEntry, int& priority) } template -bool PriorityQueue::isEmpty() const +inline bool PriorityQueue::isEmpty() const { return head == nullptr; } template -void PriorityQueue::printList() const +inline void PriorityQueue::printList() const { if (isEmpty()) return; PriorityNode* current = head; int p = 0; - while (current) { + while (current) + { std::cout << current->getItem(p); if (current->getNext() != nullptr) @@ -108,15 +107,17 @@ void PriorityQueue::printList() const } template -int PriorityQueue::getCount() const +inline int PriorityQueue::getCount() const { return itemCount; } template -PriorityQueue::~PriorityQueue() +inline PriorityQueue::~PriorityQueue() { T tmp; int p; while (dequeue(tmp, p)); -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Containers/QueueADT.h b/Containers/QueueADT.h index a4e7316..acf06af 100644 --- a/Containers/QueueADT.h +++ b/Containers/QueueADT.h @@ -1,11 +1,11 @@ -#ifndef QUEUE_ADT_ -#define QUEUE_ADT_ +#ifndef QUEUE_ADT_H +#define QUEUE_ADT_H template class QueueADT { public: - + virtual bool isEmpty() const = 0; virtual bool enqueue(const T& newEntry) = 0; @@ -15,5 +15,5 @@ class QueueADT virtual bool peek(T& FrontEntry) const = 0; virtual ~QueueADT() { } -}; +}; #endif \ No newline at end of file diff --git a/Containers/StackADT.h b/Containers/StackADT.h index 93af4d2..65d4f8a 100644 --- a/Containers/StackADT.h +++ b/Containers/StackADT.h @@ -1,5 +1,5 @@ -#ifndef STACKADT_H -#define STACKADT_H +#ifndef STACK_ADT_H +#define STACK_ADT_H template class StackADT diff --git a/UnitClasses/AlienDrone.h b/UnitClasses/AlienDrone.h index 66fc183..13cd3d6 100644 --- a/UnitClasses/AlienDrone.h +++ b/UnitClasses/AlienDrone.h @@ -1,9 +1,11 @@ -#ifndef ALIENDRONE_H -#define ALIENDRONE_H +#ifndef ALIEN_DRONE_H +#define ALIEN_DRONE_H #include "Unit.h" class AlienDrone: public Unit { - +public: + void print(); + void attack(Unit* aUnit); }; #endif diff --git a/UnitClasses/AlienMonster.h b/UnitClasses/AlienMonster.h index f150bb3..42bb1f0 100644 --- a/UnitClasses/AlienMonster.h +++ b/UnitClasses/AlienMonster.h @@ -1,9 +1,11 @@ -#ifndef ALIENMONSTER_H -#define ALIENMONSTER_H +#ifndef ALIEN_MONSTER_H +#define ALIEN_MONSTER_H #include "Unit.h" class AlienMonster: public Unit { - +public: + void print(); + void attack(Unit* aUnit); }; #endif diff --git a/UnitClasses/AlienSoldier.h b/UnitClasses/AlienSoldier.h new file mode 100644 index 0000000..9e97e12 --- /dev/null +++ b/UnitClasses/AlienSoldier.h @@ -0,0 +1,11 @@ +#ifndef ALIEN_SOLDIER_H +#define ALIEN_SOLDIER_H + +#include "Unit.h" +class AlienSoldier : public Unit +{ +public: + void print(); + void attack(Unit* aUnit); +}; +#endif diff --git a/UnitClasses/AlienSolider.h b/UnitClasses/AlienSolider.h deleted file mode 100644 index 3b7368c..0000000 --- a/UnitClasses/AlienSolider.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef ALIENSOLIDER_H -#define ALIENSOLIDER_H - -#include "Unit.h" -class AlienSolider: public Unit -{ - -}; -#endif diff --git a/UnitClasses/EarthGunnery.h b/UnitClasses/EarthGunnery.h index f07d4a6..fb966c5 100644 --- a/UnitClasses/EarthGunnery.h +++ b/UnitClasses/EarthGunnery.h @@ -1,10 +1,12 @@ -#ifndef EARTHGUNNERY_H -#define EARTHGUNNERY_H +#ifndef EARTH_GUNNERY_H +#define EARTH_GUNNERY_H #include "Unit.h" -class EearthGunnery: public Unit +class EarthGunnery: public Unit { - +public: + void print(); + void attack(Unit* aUnit); }; #endif diff --git a/UnitClasses/EarthSoldier.h b/UnitClasses/EarthSoldier.h new file mode 100644 index 0000000..8819d62 --- /dev/null +++ b/UnitClasses/EarthSoldier.h @@ -0,0 +1,11 @@ +#ifndef EARTH_SOLDIER_H +#define EARTH_SOLDIER_H + +#include "Unit.h" +class EarthSoldier : public Unit +{ +public: + void print(); + void attack(Unit* aUnit); +}; +#endif diff --git a/UnitClasses/EarthSolider.h b/UnitClasses/EarthSolider.h deleted file mode 100644 index a246d3a..0000000 --- a/UnitClasses/EarthSolider.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef EARTHSOLIDER_H -#define EARTHSOLIDER_H - -#include "Unit.h" -class EearthSolider: public Unit -{ - -}; -#endif - diff --git a/UnitClasses/EarthTank.h b/UnitClasses/EarthTank.h index 584b97d..dcfe383 100644 --- a/UnitClasses/EarthTank.h +++ b/UnitClasses/EarthTank.h @@ -1,10 +1,12 @@ -#ifndef EARTHTANK_H -#define EARTHTANK_H +#ifndef EARTH_TANK_H +#define EARTH_TANK_H #include "Unit.h" -class EearthTank: public Unit +class EarthTank: public Unit { - +public: + void print(); + void attack(Unit* aUnit); }; #endif diff --git a/UnitClasses/Unit.cpp b/UnitClasses/Unit.cpp new file mode 100644 index 0000000..a1d3f41 --- /dev/null +++ b/UnitClasses/Unit.cpp @@ -0,0 +1,6 @@ +#include "Unit.h" + +void Unit::recieveDamage(int loss) +{ + health -= loss; +} \ No newline at end of file diff --git a/UnitClasses/Unit.h b/UnitClasses/Unit.h index b439693..af0855f 100644 --- a/UnitClasses/Unit.h +++ b/UnitClasses/Unit.h @@ -28,9 +28,4 @@ class Unit virtual void attack(Unit* aUnit) = 0; //shouldn't it be passed a list??? will check later }; -#endif - -void Unit:: recieveDamage(int loss) -{ - health -= loss; -} +#endif \ No newline at end of file