Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Prison.h"
- #include <cstring>
- Prison::Prison()
- {
- prisoners_count = 0;
- guards_count = 0;
- }
- Prison::~Prison()
- {
- }
- void Prison::addGuard(const char * name, const unsigned short working_years, const unsigned short cought_criminals)
- {
- if (guards_count >= MAX_GUARD_COUNT)
- {
- cout << "Gurads limit reached, current gurads count " << guards_count << endl;;
- return;
- }
- guards[++guards_count - 1] = Guard(name, working_years, cought_criminals);
- }
- void Prison::addPrisoner(const char * name, const char * crime_group, const unsigned short crime_year)
- {
- if (prisoners_count >= MAX_PRISONER_COUNT)
- {
- cout << "Prisoners limit reached, current prisoners count " << prisoners_count << endl;;
- return;
- }
- prisoners[++prisoners_count - 1] = Prisoner(name, crime_group, crime_year);
- }
- void Prison::PrintAllPrisoners() const
- {
- for (size_t i = 0; i < prisoners_count; i++)
- {
- cout << prisoners[i].getName() << endl;
- }
- }
- void Prison::Migrate(const Prison & rhs)
- {
- // release all prisoners
- // if we set the counter to 0 The interface have no way of knowing about the other records
- prisoners_count = 0;
- for (size_t i = 0; i < rhs.prisoners_count; i++)
- {
- if (rhs.prisoners[i].getYear() >= 10)
- {
- prisoners[++prisoners_count - 1] = rhs.prisoners[i];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement