diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..37b2665c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Krzysztof Rudnicki + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/employee.cpp b/employee.cpp new file mode 100644 index 00000000..d3ac20f2 --- /dev/null +++ b/employee.cpp @@ -0,0 +1,208 @@ +#ifndef EMPLOYEE_CPP +#define EMPLOYEE_CPP + +#ifndef DIMENSION +#define DIMENSION 3 +#endif // DIMENSION + +#ifndef HAZARDS +#define HAZARDS 3 +#endif // HAZARDS + +#ifndef STATE +#define STATE 3 +#endif // STATE + +#ifndef CERTIFICATES +#define CERTIFICATES 10 +#endif // CERTIFICATES + +#include "employee.hpp" +#include "equipment.hpp" +#include "good.hpp" +#include "warehouse.hpp" +#include + +Employee::Employee(): equipmentTraining(CERTIFICATES), hazardTraining(HAZARDS), + statesTraining(STATE) +{ + for(int i = 0; i < CERTIFICATES; i++) + { + equipmentTraining[i] = 0; + } + + for(int i = 0; i < HAZARDS; i++) + { + hazardTraining[i] = 0; + } + + for(int i = 0; i < STATE; i++) + { + statesTraining[i] = 0; + } + + canRepair = 0; + + Equipment assignedEquipment; +} + +std::vector Employee::getEquipmentTraining() const +{ + return equipmentTraining; +} + +std::vector Employee::getHazardTraining() const +{ + return hazardTraining; +} + +std::vector Employee::getStatesTraining() const +{ + return statesTraining; +} + +Equipment Employee::getAssignedEquipment() const +{ + return assignedEquipment; +} + +bool Employee::getCanRepair() const +{ + return canRepair; +} + +void Employee::trainEquipment(int certificateNumber) +{ + if(certificateNumber >= 0 && certificateNumber <= CERTIFICATES - 1) + { + equipmentTraining[certificateNumber] = 1; + } +} + +void Employee::trainHazard(int certificateNumber) +{ + if(certificateNumber >= 0 && certificateNumber <= HAZARDS - 1) + { + hazardTraining[certificateNumber] = 1; + } +} + +void Employee::trainStates(int certificateNumber) +{ + if(certificateNumber >= 0 && certificateNumber <= STATE - 1) + { + statesTraining[certificateNumber] = 1; + } +} + +void Employee::trainRepair() +{ + canRepair = 1; +} + +bool Employee::canAssignEquipment(Equipment toBeAssigned) const +{ + std::vector trainingNeeded = toBeAssigned.getTrainingRequired(); + for(int i = 0; i < CERTIFICATES - 1; i++) + { + if((equipmentTraining[i] == 0) && (trainingNeeded[i] == 1)) return false; + } + return true; +} + +void Employee::assignEquipment(Equipment &newEquipment) +{ + if(canAssignEquipment(newEquipment)) assignedEquipment = newEquipment; +} + +void Employee::removeEquipment() +{ + Equipment emptyEquipment; + assignedEquipment = emptyEquipment; +} + +bool Employee::canEmployeeMoveGoodState(Good &goodToMove) const +{ + int goodState = goodToMove.getStateOfMatter(); + return statesTraining[goodState]; +} + +bool Employee::canEmployeeMoveGoodHazard(Good &goodToMove) const +{ + std::vector goodHazard = goodToMove.getHazard(); + for(int i = 0; i < HAZARDS; i++) + { + if(hazardTraining[i] == 0 && goodHazard[i] == 1) return false; + } + return true; +} + +bool Employee::canEmployeeMoveGood(Good &goodToMove) const +{ + if(!canEmployeeMoveGoodState(goodToMove)) + { + std::cout << "Employee can't move the state of this good" << std::endl; + return false; + } + if(!canEmployeeMoveGoodHazard(goodToMove)) + { + std::cout << "Employee can't move the hazards of this good" << std::endl; + return false; + } + return true; +} + +bool Employee::canMoveGood(Good &goodToMove, Equipment &toWhichMove, Equipment &fromWhichMove) const +{ + if(!toWhichMove.canMoveGood(goodToMove)) + { + std::cout << "Equipment toWhichWeMove cannot hold this good" << std::endl; + return false; + } + if(!fromWhichMove.canMoveGood(goodToMove)) + { + std::cout << "Equipment fromWhichMove cannot move this good" << std::endl; + return false; + } + if(!canEmployeeMoveGood(goodToMove)) + { + std::cout << "Employee cannot move this good" << std::endl; + return false; + } + if(!canAssignEquipment(fromWhichMove)) + { + std::cout << "Employee cannot be assigned equipment fromWhichMove" << std::endl; + return false; + } + return true; +} + +bool Employee::moveGood(Good &goodToMove, Equipment &toWhichMove, Equipment &fromWhichMove) const +{ + if(canMoveGood(goodToMove, toWhichMove, fromWhichMove)) + { + toWhichMove.setTimesUsed(toWhichMove.getTimesUsed() + 1); + fromWhichMove.setTimesUsed(fromWhichMove.getTimesUsed() + 1); + toWhichMove.occupySpaceGood(goodToMove); + return true; + } + return false; +} + +void Employee::moveGoodOverride(Good &goodToMove, Equipment &toWhichMove) const +{ + toWhichMove.setTimesUsed(toWhichMove.getTimesUsed() + 1); + toWhichMove.occupySpaceGood(goodToMove); +} + +bool Employee::repairEquipment(Equipment &toRepair) const +{ + if(getCanRepair() && toRepair.needsRepair()) + { + toRepair.setTimesUsed(0); + return true; + } + return false; +} + +#endif // EMPLOYE_CPP diff --git a/employee.hpp b/employee.hpp new file mode 100644 index 00000000..9e6ddcac --- /dev/null +++ b/employee.hpp @@ -0,0 +1,46 @@ +#ifndef EMPLOYEE_HPP +#define EMPLOYEE_HPP + +#include +#include "equipment.hpp" + +class Employee +{ + private: + std::vector equipmentTraining; + std::vector hazardTraining; + std::vector statesTraining; + bool canRepair; + Equipment assignedEquipment; + + public: + Employee(); + + std::vector getEquipmentTraining() const; + std::vector getHazardTraining() const; + std::vector getStatesTraining() const; + Equipment getAssignedEquipment() const; + bool getCanRepair() const; + + void trainEquipment(int certificateNumber); + void trainHazard(int certificateNumber); + void trainStates(int certificateNumber); + void trainRepair(); + void assignEquipment(Equipment &newEquipment); + void removeEquipment(); + + bool canAssignEquipment(Equipment toBeAssigned) const; + bool canEmployeeMoveGoodState(Good &goodToMove) const; + bool canEmployeeMoveGoodHazard(Good &goodToMove) const; + bool canEmployeeMoveGood(Good &goodToMove) const; + bool canMoveGood(Good &goodToMove, Equipment &toWhichMove, Equipment &fromWhichMove) const; + bool moveGood(Good &goodToMove, Equipment &toWhichMove, Equipment &fromWhichMove) const; + void moveGoodOverride(Good &goodToMove, Equipment &toWhichMove) const; + bool repairEquipment(Equipment &toRepair) const; + + +}; + + + +#endif diff --git a/equipment.cpp b/equipment.cpp new file mode 100644 index 00000000..9db061eb --- /dev/null +++ b/equipment.cpp @@ -0,0 +1,263 @@ +#ifndef EQUIPMENT_CPP +#define EQUIPMENT_CPP +#include "employee.hpp" +#include "equipment.hpp" +#include "good.hpp" +#include "warehouse.hpp" + +#ifndef DIMENSION +#define DIMENSION 3 +#endif // DIMENSION + +#ifndef HAZARDS +#define HAZARDS 3 +#endif // HAZARDS + +#ifndef STATE +#define STATE 3 +#endif // STATE + +#ifndef CERTIFICATES +#define CERTIFICATES 10 +#endif // CERTIFICATES + +#include + +Equipment::Equipment(): canTransportHazard(HAZARDS), canTransportState(STATE), sizeLimit(DIMENSION), sizeLeft(DIMENSION), trainingRequired(CERTIFICATES) +{ + for(int i = 0; i < HAZARDS; i++) + { + canTransportHazard[i] = 0; + } + + for(int i = 0; i < STATE; i++) + { + canTransportState[i] = 0; + } + + for(int i = 0; i < DIMENSION; i++) + { + sizeLimit[i] = 0; + } + + sizeLeft = sizeLimit; + + for(int i = 0; i < CERTIFICATES; i++) + { + trainingRequired[i] = 0; + } + + timesUsed = 0; + timesUsedLimit = 0; + weightLimit = 0; + weightLeft = 0; +} + +std::vector Equipment::getCanTranportHazard() const +{ + return canTransportHazard; +} + +void Equipment::setCanTransportHazard(std::vector newHazard) +{ + canTransportHazard = newHazard; +} + +std::vector Equipment::getCanTransportState() const +{ + return canTransportState; +} + +void Equipment::setCanTransportState(std::vector newState) +{ + canTransportState = newState; +} + +std::vector Equipment::getSizeLimit() const +{ + return sizeLimit; +} + +void Equipment::setSizeLimit(std::vector newSize) +{ + for(int i = 0; i < DIMENSION; i++) + { + if(newSize[i] >= 0) + { + int sizeOccupied = sizeLimit[i] - sizeLeft[i]; + sizeLeft[i] = newSize[i] - sizeOccupied; + sizeLimit[i] = newSize[i]; + } + } +} + +std::vector Equipment::getSizeLeft() const +{ + return sizeLeft; +} + +void Equipment::setSizeLeft(std::vector newSizeLeft) +{ + for(int i = 0; i < DIMENSION; i++) + { + if(newSizeLeft[i] >= 0 && newSizeLeft <= sizeLimit) sizeLeft[i] = newSizeLeft[i]; + } +} + +void Equipment::occupySpaceGood(Good &someGood) +{ + std::vector goodSize = someGood.getSize_(); + for(int i = 0; i < DIMENSION; i++) + { + if(goodSize[i] <= sizeLeft[i]) sizeLeft[i] -= goodSize[i]; + } +} + +int Equipment::getTimesUsed() const +{ + return timesUsed; +} + +void Equipment::setTimesUsed(int newTimesUsed) +{ + if(newTimesUsed >= 0) timesUsed = newTimesUsed; +} + +int Equipment::getTimesUsedLimit() const +{ + return timesUsedLimit; +} + +void Equipment::setTimesUsedLimit(int newTimesUsedLimit) +{ + if(newTimesUsedLimit >= 0) timesUsedLimit = newTimesUsedLimit; +} + +std::vector Equipment::getTrainingRequired() const +{ + return trainingRequired; +} + +void Equipment::setTrainingRequired(int trainingNumber) +{ + if(trainingNumber >= 0 && trainingNumber <= CERTIFICATES - 1) trainingRequired[trainingNumber] = 1; +} + +int Equipment::getWeightLimit() const +{ + return weightLimit; +} + +void Equipment::setWeightLimit(int newWeightLimit) +{ + if(newWeightLimit >= 0) weightLimit = newWeightLimit; +} + +int Equipment::getWeightLeft() const +{ + return weightLeft; +} + +void Equipment::setWeightLeft(int newWeightLeft) +{ + if(newWeightLeft >= 0) weightLeft = newWeightLeft; +} + + + +bool Equipment::canMoveHazard(Good &someGood) +{ + std::vector Hazard = someGood.getHazard(); + for(int i = 0; i < HAZARDS; i++) + { + if(canTransportHazard[i] == 0 && Hazard[i] == 1) return 0; + } + return 1; +} + +bool Equipment::canMoveState(Good &someGood) +{ + if(canTransportState[someGood.getStateOfMatter()]) return true; + return false; +} + +bool Equipment::canMoveSize(Good &someGood) +{ + std::vector goodSize = someGood.getSize_(); + for(int i = 0; i < DIMENSION; i++) + { + if(sizeLimit[i] < goodSize[i]) return false; + } + return true; +} + +bool Equipment::needsRepair() const +{ + if(timesUsed > timesUsedLimit) return true; + return false; +} + +bool Equipment::canMoveGood(Good &someGood) +{ + if(!canMoveHazard(someGood)) + { + std::cout << "This equipment cannot move good with this hazard" << std::endl; + return false; + } + if(!canMoveState(someGood)) + { + std::cout << "This equipment cannot move good with this state" << std::endl; + return false; + } + if(!canMoveSize(someGood)) + { + std::cout << "This equipment cannot move good of this size" << std::endl; + return false; + } + if(needsRepair()) + { + std::cout << "This equipment needs repair" << std::endl; + return false; + } + if(someGood.getWeight() > getWeightLeft()) + { + std::cout << "This good is too heavy to be moved by this equipment" << std::endl; + } + return true; +} + +int Equipment::volumeLimit() const +{ + int volume = 1; + for(int i = 0; i < DIMENSION; i++) + { + volume *= sizeLimit[i]; + } + return volume; +} + +int Equipment::volumeLeft() const +{ + int volume = 1; + for(int i = 0; i < DIMENSION; i++) + { + volume *= sizeLeft[i]; + } + return volume; +} + +void Equipment::operator = (Equipment const &otherEquipment) +{ + this -> canTransportHazard = otherEquipment.getCanTranportHazard(); + this -> canTransportState = otherEquipment.getCanTransportState(); + this -> sizeLimit = otherEquipment.getSizeLimit(); + this -> timesUsed = otherEquipment.getTimesUsed(); + this -> timesUsedLimit = otherEquipment.getTimesUsedLimit(); + this -> trainingRequired = otherEquipment.getTrainingRequired(); +} + + + + + +#endif // EQUIPMENT_CPP diff --git a/equipment.hpp b/equipment.hpp new file mode 100644 index 00000000..f9711e04 --- /dev/null +++ b/equipment.hpp @@ -0,0 +1,58 @@ +#ifndef EQUIPMENT_HPP +#define EQUIPMENT_HPP + +#include +#include "good.hpp" + +class Equipment +{ + private: + std::vector canTransportHazard; + std::vector canTransportState; + std::vector sizeLimit; + std::vector sizeLeft; + std::vector trainingRequired; + int timesUsed; + int timesUsedLimit; + int weightLimit; + int weightLeft; + + public: + Equipment(); + + + bool canMoveHazard(Good &someGood); + bool canMoveState(Good &someGood); + bool canMoveSize(Good &someGood); + bool canMoveGood(Good &someGood); + void occupySpaceGood(Good &someGood); + + bool needsRepair() const; + + int volumeLimit() const; + int volumeLeft() const; + + void setCanTransportState(std::vector newState); + void setCanTransportHazard(std::vector newHazard); + void setSizeLimit(std::vector newSize); + void setSizeLeft (std::vector newSizeLeft); + void setTimesUsed(int newTimesUsed); + void setTimesUsedLimit(int newTimesUsedLimit); + void setTrainingRequired(int trainingNumber); + void setWeightLimit(int newWeightLimit); + void setWeightLeft(int newWeightLeft); + + std::vector getSizeLimit() const; + std::vector getSizeLeft() const; + std::vector getCanTransportState() const; + std::vector getCanTranportHazard() const; + int getTimesUsed() const; + int getTimesUsedLimit() const; + int getWeightLimit() const; + int getWeightLeft() const; + std::vector getTrainingRequired() const; + + void operator = (Equipment const &otherEquipment); +}; + +#endif // EQUIPMENT diff --git a/firstDescriptionOfProject.pdf b/firstDescriptionOfProject.pdf new file mode 100755 index 00000000..68979fb9 Binary files /dev/null and b/firstDescriptionOfProject.pdf differ diff --git a/good.cpp b/good.cpp new file mode 100644 index 00000000..f6147126 --- /dev/null +++ b/good.cpp @@ -0,0 +1,87 @@ +#ifndef GOOD_CPP +#define GOOD_CPP +#include "employee.hpp" +#include "equipment.hpp" +#include "good.hpp" +#include "warehouse.hpp" + +#ifndef DIMENSION +#define DIMENSION 3 +#endif // DIMENSION + +#ifndef HAZARDS +#define HAZARDS 3 +#endif // HAZARDS + +#ifndef STATE +#define STATE 3 +#endif // STATE + +#ifndef CERTIFICATES +#define CERTIFICATES 10 +#endif // CERTIFICATES + + +#include + +Good::Good(): size_(DIMENSION), hazard(HAZARDS) +{ + size_ = {0, 0, 0}; + hazard = {0, 0, 0, 0}; + stateOfMatter = 0; + weight = 0; +} + +std::vector Good::getSize_() const +{ + return size_; +} + +std::vector Good::getHazard() const +{ + return hazard; +} + +int Good::getStateOfMatter() const +{ + return stateOfMatter; +} + +int Good::getWeight() const +{ + return weight; +} + +void Good::setHazard(std::vector newHazard) +{ + hazard = newHazard; +} + +void Good::setStateOfMatter(int newState) +{ + if(newState >= 0 && newState <= 2) stateOfMatter = newState; + else std::cout << "newState must be a number between 0 and 2!" << std::endl; +} + +void Good::setWeight(int newWeight) +{ + + if(newWeight > 0) weight = newWeight; +} + +void Good::setSize_(std::vector newSize) +{ + if(newSize.size() > DIMENSION) return; + for(int i = 0; i < DIMENSION; i++) + { + if(newSize[i] < 0) return; + } + size_ = newSize; +} + +int Good::volume() +{ + return size_[0] * size_[1] * size_[2]; +} + +#endif // GOOD_CPP diff --git a/good.hpp b/good.hpp new file mode 100644 index 00000000..c956f8ba --- /dev/null +++ b/good.hpp @@ -0,0 +1,34 @@ +#ifndef GOOD_HPP +#define GOOD_HPP +#include + +class Good +{ + private: + std::vector size_; + std::vector hazard; + int stateOfMatter; + unsigned int weight; + + public: + + Good(); + + std::vector getSize_() const; + std::vector getHazard() const; + int getStateOfMatter() const; + int getWeight() const; + + void setSize_(std::vector newSize); + void setHazard(std::vector newHazard); + void setStateOfMatter(int newState); + void setWeight(int newWeight); + + + int volume(); + + + +}; + +#endif // GOOD diff --git a/main.cpp b/main.cpp new file mode 100644 index 00000000..519dd8a7 --- /dev/null +++ b/main.cpp @@ -0,0 +1,1050 @@ +#include +#include "employee.hpp" +#include "equipment.hpp" +#include "good.hpp" +#include "warehouse.hpp" +#include "employee.cpp" +#include "equipment.cpp" +#include "good.cpp" +#include "warehouse.cpp" +#include +#include + +#ifndef DIMENSION +#define DIMENSION 3 +#endif // DIMENSION + +#ifndef HAZARDS +#define HAZARDS 3 +#endif // HAZARDS + +#ifndef STATE +#define STATE 3 +#endif // STATE + +#ifndef CERTIFICATES +#define CERTIFICATES 10 +#endif // CERTIFICATES + +void error_message(const std::string& message) +{ + std::cerr << "Error - " << message << "!" << std::endl; +} + + +void print(std::string s) +{ + std::cout << s << std::endl; +} + + +void printIntVector(std::vector v) // v stands for vector +{ + for(unsigned int i = 0; i < v.size(); i++) + { + std::cout << "vector[" << i << "] = " << v[i] << "; "; + } + std::cout << std::endl; +} + +void printBoolVector(std::vector v) +{ + for(unsigned int i = 0; i < v.size(); i++) + { + std::cout << "vector[" << i << "] = " << v[i] << "; "; + } + std::cout << std::endl; +} + +void printFullInfoGood(Good goodInfo) +{ + print("Good info: "); + print("Hazards: "); + printBoolVector(goodInfo.getHazard()); + print("Size: "); + printIntVector(goodInfo.getSize_()); + print("State of matter: "); + std::cout << goodInfo.getStateOfMatter() << std::endl; + print("Weight: "); + std::cout << goodInfo.getWeight() << std::endl; +} + + +void printFullInfoEquipment(Equipment equipmentInfo) +{ + print("Equipment info: "); + print("Size limit: "); + printIntVector(equipmentInfo.getSizeLimit()); + print("Can Transport State: "); + printBoolVector(equipmentInfo.getCanTransportState()); + print("Can Transport Hazard: "); + printBoolVector(equipmentInfo.getCanTranportHazard()); + std::cout << "Times Used: " << equipmentInfo.getTimesUsed() << std::endl; + std::cout << "Times used limit: " << equipmentInfo.getTimesUsedLimit() << std::endl; + print("Weight limit: "); + std::cout << equipmentInfo.getWeightLimit() << std::endl; + print("Weight left: "); + std::cout << equipmentInfo.getWeightLeft() << std::endl; +} + +void printFullInfoEmployee(Employee employeeInfo) +{ + print("Employee info: "); + print("getAssignedEquipment: "); + printFullInfoEquipment(employeeInfo.getAssignedEquipment()); + print("getCanRepair: "); + std::cout << employeeInfo.getCanRepair() << std::endl; + print("getEquipmentTraining: "); + printBoolVector(employeeInfo.getEquipmentTraining()); + print("getHazardTraining: "); + printBoolVector(employeeInfo.getHazardTraining()); + print("getStatesTraining: "); + printBoolVector(employeeInfo.getStatesTraining()); +} + +void printGoodVector(std::vector goodVector) +{ + int vectorSize = goodVector.size(); + for(int i = 0; i < vectorSize; i++) + { + std::cout << "vector[" << i << "]: " << std::endl; + printFullInfoGood(goodVector[i]); + } +} + +void printEquipmentVector(std::vector equipmentInfo) +{ + int vectorSize = equipmentInfo.size(); + for(int i = 0; i < vectorSize; i++) + { + std::cout << "vector[" << i << "]: " << std::endl; + printFullInfoEquipment(equipmentInfo[i]); + } +} + +void printEmployeeVector(std::vector employeeInfo) +{ + int vectorSize = employeeInfo.size(); + for(int i = 0; i < vectorSize; i++) + { + std::cout << "vector[" << i << "]: " << std::endl; + printFullInfoEmployee(employeeInfo[i]); + } +} + + + + + +void testGoodGetHazard() +{ + print("testGoodGetHazard"); + Good gold; + print("Object Hazards: "); + printBoolVector(gold.getHazard()); +} + +void testGoodGetSize_() +{ + print("testGoodGetSize_"); + Good gold; + print("Object size: "); + printIntVector(gold.getSize_()); +} + +void testGoodGetStateOfMatter() +{ + print("testGoodGetStateOfMatter"); + Good gold; + std::cout << "object state of matter is: " << gold.getStateOfMatter() << std::endl; +} + +void testGoodGetWeight() +{ + print("testGoodGetWeight"); + Good gold; + std::cout << "object weight is: " << gold.getWeight() << std::endl; +} + +void testGoodGetters() +{ + print("testGoodGetters"); + testGoodGetHazard(); + testGoodGetSize_(); + testGoodGetStateOfMatter(); + testGoodGetWeight(); +} + +void testGoodSetHazard() +{ + print("testGoodSetHazard"); + Good gold; + gold.setHazard({0, 1, 1, 0}); + if(gold.getHazard()[1] != 1 || gold.getHazard()[2] != 1) + { + error_message("good.setHazard does not work"); + } + print("Object hazard is: "); + printBoolVector(gold.getHazard()); +} + +void testGoodSetSize_() +{ + print("testGoodSetSize_"); + Good gold; + gold.setSize_({2, 2, 2}); + if(gold.getSize_()[0] != 2 || gold.getSize_()[1] != 2 + || gold.getSize_()[2] != 2) + { + error_message("good.setSize_ does not work"); + } + print("Object size is: "); + printIntVector(gold.getSize_()); +} + +void testGoodSetStateOfMatter() +{ + print("testGoodSetStateOfMatter"); + Good gold; + gold.setStateOfMatter(3); + if(gold.getStateOfMatter() != 0) + { + error_message("good.setStateOfMatter does not work"); + } + std::cout << "Object State of Matter is: " << gold.getStateOfMatter() << std::endl; + gold.setStateOfMatter(10); + if(gold.getStateOfMatter() != 0) + { + error_message("good.setStateOfMatter does not work"); + } + std::cout << "Object State of Matter is: " << gold.getStateOfMatter() << std::endl; + gold.setStateOfMatter(1); + if(gold.getStateOfMatter() != 1) + { + error_message("good.setStateOfMatter does not work"); + } + std::cout << "Object State of Matter is: " << gold.getStateOfMatter() << std::endl; +} + +void testGoodSetWeight() +{ + print("testGoodSetWeight"); + Good gold; + gold.setWeight(100); + if(gold.getWeight() != 100) + { + error_message("good.setStateOfMatter does not work"); + } + std::cout << "Object weight is: " << gold.getWeight() << std::endl; +} + +void testGoodSetters() +{ + print("testGoodSetters"); + testGoodSetHazard(); + testGoodSetSize_(); + testGoodSetStateOfMatter(); + testGoodSetWeight(); +} + +void testVolume() +{ + print("testGoodVolume"); + Good gold; + if(gold.volume() != 0) + { + error_message("error in good.volume() method"); + } + std::cout << "Volume of the good is equal to: " << gold.volume() << std::endl; + gold.setSize_({2, 2, 2}); + if(gold.volume() != 8) + { + error_message("error in good.volume() method"); + } + std::cout << "Volume of the good is equal to: " << gold.volume() << std::endl; +} + + + +void testEquipmentGetSizeLimit() +{ + print("testEquipmentGetSizeLimit"); + Equipment forklift; + printIntVector(forklift.getSizeLimit()); +} + +void testEquipmentGetSizeOccupied() +{ + print("testEquipmentGetSizeOccupied"); + Equipment forklift; + printIntVector(forklift.getSizeLeft()); +} + +void testEquipmentGetCanTransportState() +{ + print("testEquipmentGetCanTransportState"); + Equipment forklift; + printBoolVector(forklift.getCanTransportState()); +} + +void testEquipmentGetCanTranportHazard() +{ + print("testEquipmentGetCanTranportHazard"); + Equipment forklift; + printBoolVector(forklift.getCanTranportHazard()); +} + +void testEquipmentGetTimesUsed() +{ + print("testEquipmentGetTimesUsed"); + Equipment forklift; + std::cout << "Times used value is equal to: " << forklift.getTimesUsed() << std::endl; +} + +void testEquipmentGetTimesUsedLimit() +{ + print("testEquipmentGetTimesUsedLimit"); + Equipment forklift; + std::cout << "Times Used Limit value is equal to: " << forklift.getTimesUsedLimit() << std::endl; +} + +void testEquipmentGetters() +{ + print("Test equipment getters"); + testEquipmentGetSizeLimit(); + testEquipmentGetSizeOccupied(); + testEquipmentGetCanTransportState(); + testEquipmentGetCanTranportHazard(); + testEquipmentGetTimesUsed(); + testEquipmentGetTimesUsedLimit(); +} + +void testEquipmentSetSizeLimit() +{ + print("testEquipmentSetSizeLimit"); + Equipment forklift; + forklift.setSizeLimit({2, 2, 2}); + if(forklift.getSizeLimit()[0] != 2) + { + error_message("error in equipment.setSizeLimit"); + } + printIntVector(forklift.getSizeLimit()); + forklift.setSizeLimit({0, 0, 0}); + if(forklift.getSizeLimit()[0] != 0) + { + error_message("error in equipment.setSizeLimit"); + } + printIntVector(forklift.getSizeLimit()); + forklift.setSizeLimit({-2, -2, -2}); + if(forklift.getSizeLimit()[0] != 0) + { + error_message("error in equipment.setSizeLimit"); + } + printIntVector(forklift.getSizeLimit()); +} + +void testEquipmentSetSizeOccupied() +{ + print("testEquipmentSetSizeOccupied"); + Equipment forklift; + forklift.setSizeLeft({2, 2, 2}); + if(forklift.getSizeLeft()[0] != 0) + { + error_message("error in equipment.setSizeLeft"); + } + printIntVector(forklift.getSizeLeft()); + forklift.setSizeLimit({3, 3, 3}); + forklift.setSizeLeft({2, 2, 2}); + if(forklift.getSizeLeft()[0] != 2) + { + error_message("error in equipment.setSizeLeft"); + } + printIntVector(forklift.getSizeLeft()); +} + +void testEquipmentSetCanTransportState() +{ + print("testEquipmentSetCanTransportState"); + Equipment forklift; + forklift.setCanTransportState({1, 1, 1}); + if(forklift.getCanTransportState()[0] != 1) + { + error_message("error in equipment.setCanTransportState"); + } + printBoolVector(forklift.getCanTransportState()); +} + +void testEquipmentSetCanTransportHazard() +{ + print("testEquipmentSetCanTransportHazard"); + Equipment forklift; + forklift.setCanTransportHazard({1, 1, 1, 1}); + if(forklift.getCanTranportHazard()[0] != 1) + { + error_message("error in equipment.SetCanTransportHazard"); + } + printBoolVector(forklift.getCanTranportHazard()); +} + +void testEquipmentSetTimesUsed() +{ + print("testEquipmentSetTimesUsed"); + Equipment forklift; + forklift.setTimesUsed(5); + if(forklift.getTimesUsed() != 5) + { + error_message("Error in equipment.setTimesUsed"); + } + std::cout << "Times Used value is: " << forklift.getTimesUsed() << std::endl; + forklift.setTimesUsed(-5); + if(forklift.getTimesUsed() != 5) + { + error_message("Error in equipment.setTimesUsed"); + } + std::cout << "Times Used value is: " << forklift.getTimesUsed() << std::endl; + +} + +void testEquipmentSetTimesUsedLimit() +{ + print("testEquipmentSetTimesUsedLimit"); + Equipment forklift; + forklift.setTimesUsedLimit(5); + if(forklift.getTimesUsedLimit() != 5) + { + error_message("Error in equipment.setTimesUsedLimit"); + } + std::cout << "Times Used Limit value is: " << forklift.getTimesUsedLimit() << std::endl; + forklift.setTimesUsedLimit(-5); + if(forklift.getTimesUsedLimit() != 5) + { + error_message("Error in equipment.setTimesUsedLimit"); + } + std::cout << "Times Used Limit value is: " << forklift.getTimesUsedLimit() << std::endl; +} + +void testEquipmentSetters() +{ + print("Test equipment setters"); + testEquipmentSetSizeLimit(); + testEquipmentSetSizeOccupied(); + testEquipmentSetCanTransportState(); + testEquipmentSetCanTransportHazard(); + testEquipmentSetTimesUsed(); + testEquipmentSetTimesUsedLimit(); +} + +void testCanMoveGoodHazard() +{ + print("testCanMoveGoodHazard"); + Good gold; + Equipment forklift; + if(!forklift.canMoveHazard(gold)) + { + error_message("error in equipment.canMoveHazard"); + } + std::cout << forklift.canMoveHazard(gold) << std::endl; + gold.setHazard({1, 0, 0}); + if(forklift.canMoveHazard(gold)) + { + error_message("error in equipment.canMoveHazard"); + } + std::cout << forklift.canMoveHazard(gold) << std::endl; + forklift.setCanTransportHazard({1, 0, 0}); + if(!forklift.canMoveHazard(gold)) + { + error_message("error in equipment.canMoveHazard"); + } + std::cout << forklift.canMoveHazard(gold) << std::endl; +} + +void testCanMoveGoodState() +{ + std::cout << "testCanMoveGoodState" << std::endl; + Good gold; + Equipment forklift; + if(forklift.canMoveState(gold)) + { + error_message("error in equipmentCanMoveState"); + } + std::cout << forklift.canMoveState(gold) << std::endl; + forklift.setCanTransportState({1, 0, 0}); + if(!forklift.canMoveState(gold)) + { + error_message("error in equipmentCanMoveState"); + } + std::cout << forklift.canMoveState(gold) << std::endl; + forklift.setCanTransportState({0, 1, 0}); + if(forklift.canMoveState(gold)) + { + error_message("error in equipment.CanMoveState"); + } + std::cout << forklift.canMoveState(gold) << std::endl; +} + +void testCanMoveGoodSize() +{ + std::cout << "testCanMoveGoodSize" << std::endl; + Good gold; + Equipment forklift; + if(!forklift.canMoveSize(gold)) + { + error_message("error in equipment.CanMoveSize"); + } + std::cout << forklift.canMoveSize(gold) << std::endl; + gold.setSize_({1, 1, 1}); + if(forklift.canMoveSize(gold)) + { + error_message("error in equipment.CanMoveSize"); + } + std::cout << forklift.canMoveSize(gold) << std::endl; + forklift.setSizeLimit({2, 2, 2}); + if(!forklift.canMoveSize(gold)) + { + error_message("error in equipment.CanMoveSize"); + } + std::cout << forklift.canMoveSize(gold) << std::endl; + gold.setSize_({1, 1, 3}); + if(forklift.canMoveSize(gold)) + { + error_message("error in equipment.CanMoveSize"); + } + std::cout << forklift.canMoveSize(gold) << std::endl; + gold.setSize_({1, 3, 1}); + if(forklift.canMoveSize(gold)) + { + error_message("error in equipment.CanMoveSize"); + } + std::cout << forklift.canMoveSize(gold) << std::endl; + gold.setSize_({3, 1, 1}); + if(forklift.canMoveSize(gold)) + { + error_message("error in equipment.CanMoveSize"); + } + std::cout << forklift.canMoveSize(gold) << std::endl; +} + +void testCanMoveGoodAll() +{ + print("testCanMoveGoodAll()"); + Good gold; + Equipment forklift; + if(forklift.canMoveGood(gold)) + { + error_message("equipment.canMoveGood"); + } + std::cout << forklift.canMoveGood(gold) << std::endl; + gold.setHazard({1, 0, 0, 0}); + gold.setSize_({1, 1, 2}); + gold.setStateOfMatter(1); + if(forklift.canMoveGood(gold)) + { + error_message("equipment.canMoveGood"); + } + std::cout << forklift.canMoveGood(gold) << std::endl; + forklift.setCanTransportHazard({0, 1, 1, 1}); + forklift.setSizeLimit({3, 3, 3}); + forklift.setCanTransportState({1, 1, 1}); + if(forklift.canMoveGood(gold)) + { + error_message("equipment.canMoveGood"); + } + std::cout << forklift.canMoveGood(gold) << std::endl; + forklift.setCanTransportHazard({1, 1, 1, 1}); + forklift.setSizeLimit({3, 3, 1}); + forklift.setCanTransportState({1, 1, 1}); + if(forklift.canMoveGood(gold)) + { + error_message("equipment.canMoveGood"); + } + std::cout << forklift.canMoveGood(gold) << std::endl; + forklift.setCanTransportHazard({1, 1, 1, 1}); + forklift.setSizeLimit({3, 3, 3}); + forklift.setCanTransportState({1, 0, 1}); + if(forklift.canMoveGood(gold)) + { + error_message("equipment.canMoveGood"); + } + std::cout << forklift.canMoveGood(gold) << std::endl; + forklift.setCanTransportHazard({1, 1, 1, 1}); + forklift.setSizeLimit({3, 3, 3}); + forklift.setCanTransportState({1, 1, 1}); + if(forklift.canMoveGood(gold)) + { + error_message("equipment.canMoveGood"); + } + std::cout << forklift.canMoveGood(gold) << std::endl; +} + +void testCanMoveGood() +{ + print("testCanMoveGood"); + testCanMoveGoodHazard(); + testCanMoveGoodState(); + testCanMoveGoodSize(); + testCanMoveGoodAll(); +} + +void testTimesUsed() +{ + print("testTimesUsed"); + Equipment forklift; + forklift.setTimesUsedLimit(10); + if(forklift.needsRepair()) + { + error_message("equipment.needsRepair"); + } + std::cout << forklift.needsRepair() << std::endl; + forklift.setTimesUsed(20); + if(!forklift.needsRepair()) + { + error_message("equipment.needsRepair"); + } + std::cout << forklift.needsRepair() << std::endl; + forklift.setTimesUsedLimit(30); + if(forklift.needsRepair()) + { + error_message("equipment.needsRepair"); + } + std::cout << forklift.needsRepair() << std::endl; + } + +void testEquipmentVolumeLimit() +{ + print("testEquipmentVolumeLimit"); + Equipment forklift; + if(forklift.volumeLimit() != 0) + { + error_message("equipment.volumeLimit"); + } + std::cout << "equipment volume equal to: " << forklift.volumeLimit() << std::endl; + forklift.setSizeLimit({1, 1, 1}); + if(forklift.volumeLimit() != 1) + { + error_message("equipment.volumeLimit"); + } + std::cout << "equipment volume equal to: " << forklift.volumeLimit() << std::endl; + forklift.setSizeLimit({1, 1, 0}); + if(forklift.volumeLimit() != 0) + { + error_message("equipment.volumeLimit"); + } + std::cout << "equipment volume equal to: " << forklift.volumeLimit() << std::endl; +} + +void testEquipmentVolumeOccupied() +{ + print("testEquipmentVolumeOccupied"); + Equipment forklift; + if(forklift.volumeLeft() != 0) + { + error_message("equipment.volumeLimit"); + } + std::cout << "equipment volume equal to: " << forklift.volumeLeft() << std::endl; + forklift.setSizeLeft({1, 1, 1}); + if(forklift.volumeLeft() != 0) + { + error_message("equipment.volumeLimit"); + } + std::cout << "equipment volume equal to: " << forklift.volumeLeft() << std::endl; + forklift.setSizeLimit({2, 2, 2}); + forklift.setSizeLeft({1, 1, 1}); + if(forklift.volumeLeft() != 1) + { + error_message("equipment.volumeLimit"); + } + std::cout << "equipment volume equal to: " << forklift.volumeLeft() << std::endl; +} + +void testEquipmentChangeSizeGood() +{ + print("testEquipmentChangeSizeGood"); + Equipment forklift; + Good gold; + forklift.occupySpaceGood(gold); + if(forklift.getSizeLeft()[0] != 0) + { + error_message("Error in equipment.occupySpaceGood"); + } + printIntVector(forklift.getSizeLeft()); + gold.setSize_({1, 1, 1}); + forklift.occupySpaceGood(gold); + if(forklift.getSizeLeft()[0] != 0) + { + error_message("Error in equipment.occupySpaceGood"); + } + printIntVector(forklift.getSizeLeft()); + forklift.setSizeLimit({2, 2, 2}); + forklift.occupySpaceGood(gold); + if(forklift.getSizeLeft()[0] != 1) + { + error_message("Error in equipment.occupySpaceGood"); + } + printIntVector(forklift.getSizeLeft()); + +} + + + +void testEmployeeGetEquipmentTraining() +{ + print("testEmployeeGetEquipmentTraining"); + Employee marcel; + printBoolVector(marcel.getEquipmentTraining()); +} + +void testEmployeeGetHazardTraining() +{ + print("testEmployeeGetHazardTraining"); + Employee marcel; + printBoolVector(marcel.getHazardTraining()); +} + +void testEmployeeGetStatesTraining() +{ + print("testEmployeeGetStatesTraining"); + Employee marcel; + printBoolVector(marcel.getStatesTraining()); +} + +void testEmployeeGetAssignedEquipment() +{ + print("testEmployeeGetAssignedEquipment"); + Employee marcel; + printFullInfoEquipment(marcel.getAssignedEquipment()); + +} + +void testEmployeeGetCanRepair() +{ + print("testEmployeeGetCanRepair"); + Employee marcel; + std::cout << marcel.getCanRepair(); +} + +void testEmployeeGetters() +{ + print("Test employee Getters "); + testEmployeeGetEquipmentTraining(); + testEmployeeGetHazardTraining(); + testEmployeeGetStatesTraining(); + testEmployeeGetAssignedEquipment(); + testEmployeeGetCanRepair(); +} + +void testEmployeeSetEquipmentTraining() +{ + print("testEmployeeSetEquipmentTraining"); + Employee marcel; + if(marcel.getEquipmentTraining()[0] != 0) + { + error_message("employee.setEquipmentTraining"); + } + printBoolVector(marcel.getEquipmentTraining()); + marcel.trainEquipment(2); + if(marcel.getEquipmentTraining()[2] != 1) + { + error_message("employee.setEquipmentTraining"); + } + printBoolVector(marcel.getEquipmentTraining()); + marcel.trainEquipment(-5); + if(marcel.getEquipmentTraining()[5] != 0) + { + error_message("employee.setEquipmentTraining"); + } + printBoolVector(marcel.getEquipmentTraining()); + marcel.trainEquipment(20); + if(marcel.getEquipmentTraining()[0] != 0) + { + error_message("employee.setEquipmentTraining"); + } + printBoolVector(marcel.getEquipmentTraining()); +} + +void testEmployeeSetHazardTraining() +{ + print("testEmployeeSetHazardTraining"); + Employee marcel; + if(marcel.getHazardTraining()[0] != 0) + { + error_message("employee.setHazardTraining"); + } + printBoolVector(marcel.getHazardTraining()); + marcel.trainHazard(1); + if(marcel.getHazardTraining()[1] != 1) + { + error_message("employee.setHazardTraining"); + } + printBoolVector(marcel.getHazardTraining()); + marcel.trainHazard(9); + if(marcel.getHazardTraining()[0] != 0) + { + error_message("employee.setHazardTraining"); + } + printBoolVector(marcel.getHazardTraining()); + marcel.trainHazard(-4); + if(marcel.getHazardTraining()[0] != 0) + { + error_message("employee.setHazardTraining"); + } + printBoolVector(marcel.getHazardTraining()); +} + +void testEmployeeSetStatesTraining() +{ + print("testEmployeeSetStatesTraining"); + Employee marcel; + if(marcel.getStatesTraining()[0] != 0) + { + error_message("employee.setStatesTraining"); + } + printBoolVector(marcel.getStatesTraining()); + marcel.trainStates(1); + if(marcel.getStatesTraining()[1] != 1) + { + error_message("employee.setStatesTraining"); + } + printBoolVector(marcel.getStatesTraining()); + marcel.trainStates(6); + if(marcel.getStatesTraining()[1] != 1) + { + error_message("employee.setStatesTraining"); + } + printBoolVector(marcel.getStatesTraining()); + marcel.trainStates(-3); + if(marcel.getStatesTraining()[1] != 1) + { + error_message("employee.setStatesTraining"); + } + printBoolVector(marcel.getStatesTraining()); +} + +void testEmployeeSetAssignedEquipment() +{ + print("testEmployeeSetAssignedEquipment"); + Employee marcel; + Equipment forklift; + forklift.setCanTransportHazard({1, 1, 1}); + forklift.setCanTransportState({1, 1, 1}); + forklift.setSizeLimit({2, 2, 2}); + forklift.setTimesUsed(1); + forklift.setTimesUsedLimit(20); + forklift.setTrainingRequired(1); + marcel.assignEquipment(forklift); + if(marcel.canAssignEquipment(forklift)) + { + error_message("error in employee.canAssignEquipment"); + } + printFullInfoEquipment(marcel.getAssignedEquipment()); + marcel.trainEquipment(1); + marcel.assignEquipment(forklift); + if(!marcel.canAssignEquipment(forklift)) + { + error_message("error in employee.canAssignEquipment"); + } + printFullInfoEquipment(marcel.getAssignedEquipment()); + marcel.removeEquipment(); + printFullInfoEquipment(marcel.getAssignedEquipment()); +} + +void testEmployeeSetCanRepair() +{ + print("testEmployeeSetCanRepair"); + Employee marcel; + if(marcel.getCanRepair()) + { + error_message("Error in employee.setRepair"); + } + std::cout << marcel.getCanRepair() << std::endl; + marcel.trainRepair(); + if(!marcel.getCanRepair()) + { + error_message("Error in employee.setRepair"); + } + std::cout << marcel.getCanRepair() << std::endl; +} + + +void testEmployeeSetters() +{ + print("Test employee Setters "); + testEmployeeSetEquipmentTraining(); + testEmployeeSetHazardTraining(); + testEmployeeSetStatesTraining(); + testEmployeeSetAssignedEquipment(); + testEmployeeSetCanRepair(); +} + +void testEmployeeRepairEquipment() +{ + print("testEmployeeRepairEquipment"); + Employee marcel; + Equipment forklift; + forklift.setTimesUsedLimit(10); + std::cout << marcel.repairEquipment(forklift) << std::endl; + if(forklift.getTimesUsed() != 0) + { + error_message("employee.repairEquipment"); + } + std::cout << "times used: " << forklift.getTimesUsed() << std::endl; + forklift.setTimesUsed(20); + std::cout << marcel.repairEquipment(forklift) << std::endl; + if(forklift.getTimesUsed() != 20) + { + error_message("employee.repairEquipment"); + } + std::cout << "times used: " << forklift.getTimesUsed() << std::endl; + marcel.trainRepair(); + std::cout << marcel.repairEquipment(forklift) << std::endl; + if(forklift.getTimesUsed() != 0) + { + error_message("employee.repairEquipment"); + } + std::cout << "times used: " << forklift.getTimesUsed() << std::endl; + std::cout << marcel.repairEquipment(forklift) << std::endl; + if(forklift.getTimesUsed() != 0) + { + error_message("employee.repairEquipment"); + } + std::cout << "times used: " << forklift.getTimesUsed() << std::endl; +} + +void testEmployeeMoveGood() +{ + print("testEmployeeMoveGood"); + Employee marcel; + Equipment forklift_1; + Equipment forklift_2; + Good gold; + gold.setSize_({2, 2, 2}); + forklift_1.setSizeLimit({3, 3, 3}); + forklift_2.setSizeLimit({4, 4, 4}); + if(marcel.canMoveGood(gold, forklift_1, forklift_2)) + { + error_message("employee.canMoveGood"); + } + std::cout << marcel.moveGood(gold, forklift_1, forklift_2) << std::endl; + forklift_1.setCanTransportState({1, 1, 1}); + forklift_2.setCanTransportState({1, 1, 1}); + forklift_1.setTimesUsedLimit({1}); + forklift_2.setTimesUsedLimit({1}); + if(marcel.canMoveGood(gold, forklift_1, forklift_2)) + { + error_message("employee.canMoveGood"); + } + std::cout << marcel.moveGood(gold, forklift_1, forklift_2) << std::endl; + marcel.trainStates(0); + if(!marcel.canMoveGood(gold, forklift_1, forklift_2)) + { + error_message("employee.canMoveGood"); + } + std::cout << marcel.moveGood(gold, forklift_1, forklift_2) << std::endl; + printIntVector(forklift_2.getSizeLeft()); +} + +void testGoods() +{ + print("testGoods"); + testGoodGetters(); + testGoodSetters(); + testVolume(); +} + +void testEquipment() +{ + print("testEquipment"); + testEquipmentGetters(); + testEquipmentSetters(); + testCanMoveGood(); + testTimesUsed(); + testEquipmentVolumeLimit(); + testEquipmentVolumeOccupied(); + testEquipmentChangeSizeGood(); +} + +void testEmployee() +{ + print("testEmployee"); + testEmployeeGetters(); + testEmployeeSetters(); + testEmployeeRepairEquipment(); + testEmployeeMoveGood(); +} + +void testWarehouseGetters() +{ + print("testWarehouseGetters"); + Warehouse magazyn; + printGoodVector(magazyn.getAllGoods()); + printEquipmentVector(magazyn.getAllEquipment()); + printEmployeeVector(magazyn.getAllEmployees()); +} + +void testWarehouseAddEquipment() +{ + print("testWarehouseAddEquipment"); + Warehouse magazyn; + Equipment forklift; + magazyn.addEquipment(forklift); + printEquipmentVector(magazyn.getAllEquipment()); +} + +void testWarehouseAddEmployee() +{ + Warehouse magazyn; + Employee marcel; + magazyn.addEmployee(marcel); + printEmployeeVector(magazyn.getAllEmployees()); + marcel.trainEquipment(5); + printEmployeeVector(magazyn.getAllEmployees()); +} + +void testWarehouseAddGood() +{ + print("testWarehouseAddGood"); + Warehouse magazyn; + Good gold; + magazyn.addGood(gold); + printGoodVector(magazyn.getAllGoods()); + Employee marcel; + magazyn.addEmployee(marcel); + magazyn.addGood(gold); + printGoodVector(magazyn.getAllGoods()); + marcel.trainStates(0); + magazyn.addGood(gold); + printGoodVector(magazyn.getAllGoods()); + Equipment forklift; + magazyn.addEquipment(forklift); + magazyn.addGood(gold); + printGoodVector(magazyn.getAllGoods()); + forklift.setCanTransportState({1, 1, 1}); + magazyn.addGood(gold); + printGoodVector(magazyn.getAllGoods()); + forklift.setTimesUsedLimit(20); + magazyn.addGood(gold); + printGoodVector(magazyn.getAllGoods()); +} + +void testWarehouseAdd() +{ + print("testWarehouseAdd"); + testWarehouseAddEquipment(); + testWarehouseAddEmployee(); + testWarehouseAddGood(); +} + +void testWarehouse() +{ + print("testWarehouse"); + testWarehouseGetters(); + testWarehouseAdd(); +} + +int main() +{ + testGoods(); + testEquipment(); + testEmployee(); + testWarehouse(); + return 0; +} diff --git a/readme.md b/readme.md new file mode 100644 index 00000000..57c95819 --- /dev/null +++ b/readme.md @@ -0,0 +1,2 @@ +To compile it just write: +g++ main.cpp diff --git a/warehouse.cpp b/warehouse.cpp new file mode 100644 index 00000000..8a9b36ce --- /dev/null +++ b/warehouse.cpp @@ -0,0 +1,205 @@ +#ifndef WAREHOUSE_CPP +#define WAREHOUSE_CPP + +#ifndef DIMENSION +#define DIMENSION 3 +#endif // DIMENSION + +#ifndef HAZARDS +#define HAZARDS 3 +#endif // HAZARDS + +#ifndef STATE +#define STATE 3 +#endif // STATE + +#ifndef CERTIFICATES +#define CERTIFICATES 10 +#endif // CERTIFICATES + +#include "employee.hpp" +#include "equipment.hpp" +#include "good.hpp" +#include "warehouse.hpp" +#include +#include + + +Warehouse::Warehouse(): size_(DIMENSION) +{ + for(int i = 0; i < DIMENSION; i++) + { + size_[i] = 0; + } +} + +std::vector Warehouse::getAllEmployees() const +{ + std::vector returnEmployees; + int howManyEmployees = allEmployees.size(); + for(int i = 0; i < howManyEmployees; i++) + { + returnEmployees.push_back(*allEmployees[i]); + } + return returnEmployees; +} + +std::vector Warehouse::getAllEquipment() const +{ + std::vector returnEquipment; + int howMuchEquipment = allEquipment.size(); + for(int i = 0; i < howMuchEquipment; i++) + { + returnEquipment.push_back(*allEquipment[i]); + } + return returnEquipment; +} + +std::vector Warehouse::getAllGoods() const +{ + std::vector returnGoods;; + int howMuchGoods = allGoods.size(); + for(int i = 0; i < howMuchGoods; i++) + { + returnGoods.push_back(*allGoods[i]); + } + return returnGoods; +} + +std::vector Warehouse::findSuitableEmployees(Good &goodToShip) +{ + int howManyEmployees = allEmployees.size(); + if(howManyEmployees == 0) return {-1}; + std::vector goodEmployeesID(howManyEmployees); + goodEmployeesID[0] = -1; + for(int i = 0; i < howManyEmployees; i++) + { + if(allEmployees[i] -> canEmployeeMoveGood(goodToShip)) goodEmployeesID.push_back(i); + } + return goodEmployeesID; +} + +std::vector Warehouse::findSuitableEquipments(Good &goodToShip) +{ + int howMuchEquipment = allEquipment.size(); + if(howMuchEquipment == 0) return {-1}; + std::vector goodEquipmentID(howMuchEquipment); + goodEquipmentID[0] = -1; + for(int i = 0; i < howMuchEquipment; i++) + { + if(allEquipment[i] -> canMoveGood(goodToShip)) goodEquipmentID.push_back(i); + } + return goodEquipmentID; +} + +std::vector Warehouse::equipmentAndEmployees(std::vector goodEmployeesID, std::vector goodEquipmentID) +{ + + std::vector equipmentEmployeeCombo = {-1, -1}; + int goodEmployeesSize = goodEmployeesID.size(); + int goodEquipmentSize = goodEquipmentID.size(); + for(int i = 0; i < goodEmployeesSize; i++) + { + for(int j = 0; j < goodEquipmentSize; j++) + { + if(allEmployees[i] -> canAssignEquipment(*allEquipment[j])) + { + equipmentEmployeeCombo[0] = i; + equipmentEmployeeCombo[1] = j; + return equipmentEmployeeCombo; + } + } + } + return equipmentEmployeeCombo; +} + +std::vector Warehouse::canAddGood(Good &goodToAdd) +{ + std::vector goodEmployees = findSuitableEmployees(goodToAdd); + if(goodEmployees.size() == 1) + { + std::cout << "No employee can move this good" << std::endl; + return {-1}; + } + std::vector goodEquipment = findSuitableEquipments(goodToAdd); + if(goodEquipment.size() == 1) + { + std::cout << "No equipment can move this good" << std::endl; + return {-1}; + } + std::vector employeeAndEquipment = equipmentAndEmployees(goodEmployees, goodEquipment); + if(employeeAndEquipment[0] == -1) + { + std::cout << "Employee and equipment that can move this good are not compatible" << std::endl; + return {-1}; + } + return employeeAndEquipment; +} + +bool Warehouse::addGood(Good &goodToShip) +{ + std::vector employeeAndEquipment = canAddGood(goodToShip); + if(employeeAndEquipment[0] != -1) + { + allEmployees[employeeAndEquipment[0]] -> moveGoodOverride(goodToShip, *allEquipment[employeeAndEquipment[1]]); + allGoods.push_back(&goodToShip); + return true; + } + return false; +} + +bool Warehouse::shipGoods(std::vector &goodsToShip) +{ + int howMuchGoods = goodsToShip.size(); + for(int i = 0; i < howMuchGoods; i++) + { + if(!addGood(goodsToShip[i])) return false; + } + return true; +} + +int Warehouse::calculateVolume() const +{ + int volume = 1; + for(int i = 0; i < DIMENSION; i++) + { + volume += size_[i]; + } + return volume; +} + +std::vector Warehouse::capacityLeft() const +{ + int equipmentNumber = allEquipment.size(); + std::vector capacity(DIMENSION); + for(int i = 0; i < equipmentNumber; i++) + { + capacity[i] += allEquipment[i] -> getSizeLeft()[i]; + } + return capacity; +} + +std::vector Warehouse::capacityTotal() const +{ + int equipmentNumber = allEquipment.size(); + std::vector capacity(DIMENSION); + for(int i = 0; i < equipmentNumber; i++) + { + capacity[i] += allEquipment[i] -> getSizeLimit()[i]; + } + return capacity; +} + +void Warehouse::addEmployee(Employee &newEmployee) +{ + allEmployees.push_back(&newEmployee); +} + +void Warehouse::addEquipment(Equipment &equipmentToAdd) +{ + allEquipment.push_back(&equipmentToAdd); +} + + + +#endif // WAREHOUSE_CPP diff --git a/warehouse.hpp b/warehouse.hpp new file mode 100644 index 00000000..94d6957d --- /dev/null +++ b/warehouse.hpp @@ -0,0 +1,41 @@ +#ifndef WAREHOUSE_HPP +#define WAREHOUSE_HPP + +#include +#include "employee.hpp" +#include "equipment.hpp" +#include "good.hpp" + +class Warehouse +{ + private: + + std::vector allEmployees; + std::vector allEquipment; + std::vector allGoods; + std::vector size_; + public: + Warehouse(); + + std::vector getAllEmployees() const; + std::vector getAllEquipment() const; + std::vector getAllGoods() const; + + std::vector findSuitableEmployees(Good &goodToShip); + std::vector findSuitableEquipments(Good &goodToShip); + std::vector equipmentAndEmployees(std::vector goodEmployeesID, std::vector goodEquipmentID); + bool canShipGoods(std::vector &goodToShip); + bool shipGoods(std::vector &goodsToShip); + int calculateVolume() const; + std::vector capacityLeft() const; + std::vector capacityTotal() const; + + void addEmployee(Employee &newEmployee); + void addEquipment(Equipment &equipmentToAdd); + std::vector canAddGood(Good &goodToAdd); + bool addGood(Good &goodToShip); + void addGoodOverride(Good &goodToShip); + +}; + +#endif // WAREHOUSE