diff --git a/Solutions/Stareat0707/Game Shop/Game Shop, Part 1/Item.cpp b/Solutions/Stareat0707/Game Shop/Game Shop, Part 1/Item.cpp new file mode 100644 index 0000000..4c176c6 --- /dev/null +++ b/Solutions/Stareat0707/Game Shop/Game Shop, Part 1/Item.cpp @@ -0,0 +1,13 @@ +#include "Item.h" + +Item::Item(std::string name, std::string description, int weight, int value) : name(name), description(description), weight(weight), value(value) +{ +} + +void Item::Describe() +{ + std::cout << "Name = " << name << std::endl; + std::cout << "Description = " << description << std::endl; + std::cout << "Weight = " << weight << " lbs" << std::endl; + std::cout << "Value = " << value << " coins" << std::endl; +} \ No newline at end of file diff --git a/Solutions/Stareat0707/Game Shop/Game Shop, Part 1/Item.h b/Solutions/Stareat0707/Game Shop/Game Shop, Part 1/Item.h new file mode 100644 index 0000000..2ba2385 --- /dev/null +++ b/Solutions/Stareat0707/Game Shop/Game Shop, Part 1/Item.h @@ -0,0 +1,16 @@ +#pragma once +#include +#include + +class Item +{ +public: + Item(std::string, std::string, int, int); + void Describe(); + +protected: + std::string name; + std::string description; + int weight; + int value; +}; \ No newline at end of file diff --git a/Solutions/Stareat0707/Game Shop/Game Shop, Part 1/Main.cpp b/Solutions/Stareat0707/Game Shop/Game Shop, Part 1/Main.cpp new file mode 100644 index 0000000..8e9ea09 --- /dev/null +++ b/Solutions/Stareat0707/Game Shop/Game Shop, Part 1/Main.cpp @@ -0,0 +1,14 @@ +#include "Item.h" + +int main() +{ + Item* item = new Item("Excalibur", "The legendary sword of King Arthur", 12, 1024, 24); + item->Describe(); + delete item; + + std::cout << std::endl; + + item = new Item("Steel Armor", "Protective covering made by steel", 15, 805, 18); + item->Describe(); + delete item; +} \ No newline at end of file diff --git a/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Armor.cpp b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Armor.cpp new file mode 100644 index 0000000..a27d91b --- /dev/null +++ b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Armor.cpp @@ -0,0 +1,11 @@ +#include "Armor.h" + +Armor::Armor(std::string name, std::string description, int weight, int value, int defense) : Item(name, description, weight, value), defense(defense) +{ +} + +void Armor::Describe() +{ + Item::Describe(); + std::cout << "Defense = " << defense << std::endl; +} \ No newline at end of file diff --git a/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Armor.h b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Armor.h new file mode 100644 index 0000000..5577a26 --- /dev/null +++ b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Armor.h @@ -0,0 +1,13 @@ +#pragma once +#include "Item.h" + +class Armor : + public Item +{ +public: + Armor(std::string, std::string, int, int, int); + void Describe(); + +private: + int defense; +}; \ No newline at end of file diff --git a/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Item.cpp b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Item.cpp new file mode 100644 index 0000000..4c176c6 --- /dev/null +++ b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Item.cpp @@ -0,0 +1,13 @@ +#include "Item.h" + +Item::Item(std::string name, std::string description, int weight, int value) : name(name), description(description), weight(weight), value(value) +{ +} + +void Item::Describe() +{ + std::cout << "Name = " << name << std::endl; + std::cout << "Description = " << description << std::endl; + std::cout << "Weight = " << weight << " lbs" << std::endl; + std::cout << "Value = " << value << " coins" << std::endl; +} \ No newline at end of file diff --git a/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Item.h b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Item.h new file mode 100644 index 0000000..9234c25 --- /dev/null +++ b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Item.h @@ -0,0 +1,16 @@ +#pragma once +#include +#include + +class Item +{ +public: + Item(std::string, std::string, int, int); + virtual void Describe(); + +protected: + std::string name; + std::string description; + int weight; + int value; +}; \ No newline at end of file diff --git a/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Main.cpp b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Main.cpp new file mode 100644 index 0000000..7f26538 --- /dev/null +++ b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Main.cpp @@ -0,0 +1,15 @@ +#include "Armor.h" +#include "Weapon.h" + +int main() +{ + Item* item = new Weapon("Excalibur", "The legendary sword of King Arthur", 12, 1024, 24); + item->Describe(); + delete item; + + std::cout << std::endl; + + item = new Armor("Steel Armor", "Protective covering made by steel", 15, 805, 18); + item->Describe(); + delete item; +} \ No newline at end of file diff --git a/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Weapon.cpp b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Weapon.cpp new file mode 100644 index 0000000..4376f34 --- /dev/null +++ b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Weapon.cpp @@ -0,0 +1,11 @@ +#include "Weapon.h" + +Weapon::Weapon(std::string name, std::string description, int weight, int value, int damage) : Item(name, description, weight, value), damage(damage) +{ +} + +void Weapon::Describe() +{ + Item::Describe(); + std::cout << "Damage = " << damage << std::endl; +} \ No newline at end of file diff --git a/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Weapon.h b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Weapon.h new file mode 100644 index 0000000..aebbc28 --- /dev/null +++ b/Solutions/Stareat0707/Game Shop/Game Shop, Part 2/Weapon.h @@ -0,0 +1,13 @@ +#pragma once +#include "Item.h" + +class Weapon : + public Item +{ +public: + Weapon(std::string, std::string, int, int, int); + void Describe(); + +private: + int damage; +}; \ No newline at end of file