Created
January 9, 2018 10:56
-
-
Save Romain-P/09da0b470eb0e28ef4e2adcdaffd1895 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "Borg.hpp" | |
| #include "Federation.hpp" | |
| #include <string> | |
| #include <iostream> | |
| Borg::Ship::Ship() { | |
| std::cout << "We are the Borgs. Lower your shields and surrender yourselves unconditionally." << std::endl; | |
| std::cout << "Your biological characteristics and technologies will be assimilated." << std::endl; | |
| std::cout << "Resistance is futile." << std::endl; | |
| } | |
| Borg::Ship::~Ship() { | |
| } | |
| void Borg::Ship::setupCore(WarpSystem::Core *core) { | |
| this->_core = core; | |
| } | |
| void Borg::Ship::checkCore() { | |
| bool stable = this->_core && this->_core->checkReactor() && this->_core->checkReactor()->isStable(); | |
| if (stable) | |
| std::cout << "Everything is in order." << std::endl; | |
| else | |
| std::cout << "Critical failure imminent." << std::endl; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef BORG_HPP_ | |
| # define BORG_HPP_ | |
| # include "WarpSystem.hpp" | |
| namespace Borg { | |
| class Ship { | |
| private: | |
| const int _length = 300; | |
| const short _maxWarp = 9; | |
| WarpSystem::Core *_core; | |
| public: | |
| Ship(); | |
| ~Ship(); | |
| void setupCore(WarpSystem::Core *core); | |
| void checkCore(); | |
| }; | |
| }; | |
| #endif /* !BORG_HPP_ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "Federation.hpp" | |
| #include <string> | |
| #include <iostream> | |
| Federation::Starfleet::Captain::Captain(std::string name) : _name(name) {} | |
| int Federation::Starfleet::Captain::getAge() { | |
| return this->_age; | |
| } | |
| std::string Federation::Starfleet::Captain::getName() { | |
| return this->_name; | |
| } | |
| void Federation::Starfleet::Captain::setAge(int age) { | |
| this->_age = age; | |
| } | |
| Federation::Starfleet::Captain::~Captain() {} | |
| Federation::Starfleet::Ensign::Ensign(std::string name) : _name(name) { | |
| std::cout << "Ensign " << name << ", awaiting orders." << std::endl; | |
| } | |
| Federation::Starfleet::Ship::Ship(int length, int width, std::string name, short maxWarp) | |
| : _length(length), _width(width), _name(name), _maxWarp(maxWarp) | |
| { | |
| std::cout << "The ship USS " << name << " has been finished. It is " << length << " m in length and " << width << " m in width." << std::endl; | |
| std::cout << "It can go to Warp " << maxWarp << "!" << std::endl; | |
| } | |
| Federation::Starfleet::Ship::~Ship() { | |
| } | |
| void Federation::Starfleet::Ship::setupCore(WarpSystem::Core *core) { | |
| this->_core = core; | |
| std::cout << "USS " << this->_name << ": The core is set." << std::endl; | |
| } | |
| void Federation::Starfleet::Ship::checkCore() { | |
| bool stable = this->_core && this->_core->checkReactor() && this->_core->checkReactor()->isStable(); | |
| std::cout << "USS " << this->_name << ": The core is " << (stable ? "stable" : "unstable") << " at the time." << std::endl; | |
| } | |
| void Federation::Starfleet::Ship::promote(Federation::Starfleet::Captain *captain) { | |
| this->_captain = captain; | |
| std::cout << captain->getName() << ": I'm glad to be the captain of the USS " << this->_name << "." << std::endl; | |
| } | |
| Federation::Ship::Ship(int length, int width, std::string name) | |
| : _length(length), _width(width), _name(name) | |
| { | |
| std::cout << "The independant ship " << name << " just finished its construction. It is " << length << " m in length and " << width << " m in width." <<\ | |
| std::endl; | |
| } | |
| Federation::Ship::~Ship() { | |
| } | |
| void Federation::Ship::setupCore(WarpSystem::Core *core) { | |
| this->_core = core; | |
| std::cout << this->_name << ": The core is set." << std::endl; | |
| } | |
| void Federation::Ship::checkCore() { | |
| bool stable = this->_core && this->_core->checkReactor() && this->_core->checkReactor()->isStable(); | |
| std::cout << this->_name << ": The core is " << (stable ? "stable" : "unstable") << " at the time." << std::endl; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef FEDERATION_HPP_ | |
| # define FEDERATION_HPP_ | |
| # include <string> | |
| # include "WarpSystem.hpp" | |
| namespace Federation { | |
| namespace Starfleet { | |
| class Ensign { | |
| private: | |
| Ensign(); | |
| const std::string _name; | |
| public: | |
| Ensign(std::string name); | |
| }; | |
| class Captain { | |
| private: | |
| const std::string _name; | |
| int _age; | |
| public: | |
| Captain(std::string _name); | |
| ~Captain(); | |
| std::string getName(); | |
| int getAge(); | |
| void setAge(int age); | |
| }; | |
| class Ship { | |
| private: | |
| const int _length; | |
| const int _width; | |
| const std::string _name; | |
| const short _maxWarp; | |
| WarpSystem::Core *_core; | |
| Captain *_captain; | |
| public: | |
| Ship(int length, int width, std::string name, short maxWarp); | |
| ~Ship(); | |
| void setupCore(WarpSystem::Core *core); | |
| void checkCore(); | |
| void promote(Captain *captain); | |
| }; | |
| }; | |
| class Ship { | |
| private: | |
| const int _length; | |
| const int _width; | |
| const std::string _name; | |
| const short _maxWarp = 1; | |
| WarpSystem::Core *_core; | |
| public: | |
| Ship(int length, int width, std::string name); | |
| ~Ship(); | |
| void setupCore(WarpSystem::Core *core); | |
| void checkCore(); | |
| }; | |
| }; | |
| #endif /* !FEDERATION_HPP_ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "WarpSystem.hpp" | |
| bool WarpSystem::QuantumReactor::isStable() { | |
| return this->_stability; | |
| } | |
| void WarpSystem::QuantumReactor::setStability(bool stability) { | |
| this->_stability = stability; | |
| } | |
| WarpSystem::Core::Core(WarpSystem::QuantumReactor *reactor) { | |
| this->_coreReactor = reactor; | |
| } | |
| WarpSystem::Core::~Core() { | |
| } | |
| WarpSystem::QuantumReactor *WarpSystem::Core::checkReactor() { | |
| return this->_coreReactor; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef WARPSYSTEM_HPP_ | |
| # define WARPSYSTEM_HPP_ | |
| namespace WarpSystem { | |
| class QuantumReactor { | |
| private: | |
| bool _stability = true; | |
| public: | |
| bool isStable(); | |
| void setStability(bool stability); | |
| }; | |
| class Core { | |
| private: | |
| QuantumReactor *_coreReactor; | |
| public: | |
| Core(QuantumReactor *reactor); | |
| ~Core(); | |
| QuantumReactor *checkReactor(); | |
| }; | |
| }; | |
| #endif /* !WARPSYSTEM_HPP_ */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment