diff --git a/src/Management.cpp b/src/Management.cpp index b790c51..cc9342b 100644 --- a/src/Management.cpp +++ b/src/Management.cpp @@ -1,5 +1,5 @@ #include "../include/manage/Management.hpp" - +#include Management::Management() { this->csv_path_room_ = ""; @@ -135,6 +135,13 @@ void Management::charge(std::string bot){ void Management::cleaning(Robot& robot, Room& room, int time){ bool fail; + int size; + int roundedUp; + if (robot.get_size() == Robot_Size::Medium){ + size = 2; + } else if (robot.get_size() == Robot_Size::Small){ + size = 3; + } else{ size = 1; } for (int i = 0; i < time; i++) { std::random_device rd; // Obtain a random number from hardware std::mt19937 gen(rd()); // Seed the generator @@ -155,9 +162,11 @@ void Management::cleaning(Robot& robot, Room& room, int time){ return; } std::this_thread::sleep_for(std::chrono::seconds(1)); - room.set_time_to_clean(time-i); + roundedUp = static_cast(ceil((time-i)/size)); + room.set_time_to_clean(roundedUp); robot.kill_battery(); } + std::cout << "\n [SYSTEM_ALERT] (Room " + room.get_id() + " is clean.)" << std::endl; room.set_status(Room_Status::clean); room.set_time_to_clean(0); robot.go_home(); diff --git a/tests/robot_test.csv b/tests/robot_test.csv index 243a5f1..0cdb58e 100644 --- a/tests/robot_test.csv +++ b/tests/robot_test.csv @@ -1,7 +1,7 @@ 0,Free,Small,Mop,NA -1,Busy,Small,Vac,2 +1,Free,Small,Vac,NA 2,Free,Medium,Scrub,NA -3,Busy,Medium,Mop,5 +3,Free,Medium,Mop,NA 4,Free,Large,Vac,NA -5,Busy,Large,Scrub,3 +5,Free,Large,Scrub,NA 6,Free,Large,Mop,NA \ No newline at end of file diff --git a/tests/room_test.csv b/tests/room_test.csv index 23f8402..efadc4c 100644 --- a/tests/room_test.csv +++ b/tests/room_test.csv @@ -1,7 +1,7 @@ -0,Clean,Small,0 -1,Dirty,Small,2 -2,IP,Medium,4 -3,IP,Medium,4 -4,Clean,Large,0 -5,IP,Large,6 -6,Clean,Large,0 \ No newline at end of file +0,Dirty,Small,3 +1,Dirty,Small,3 +2,Dirty,Medium,3 +3,Dirty,Medium,3 +4,Dirty,Large,3 +5,Dirty,Large,3 +6,Dirty,Large,3 \ No newline at end of file