diff --git a/src/08_PTRN/CMakeLists.txt b/src/08_PTRN/CMakeLists.txt index 66ff7c8..b40f610 100644 --- a/src/08_PTRN/CMakeLists.txt +++ b/src/08_PTRN/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(08_PTRN_MP MP/VehicleFactory.cpp MP/VehicleFactory.hpp MP/Vehicle.cpp MP/Vehicle.hpp MP/Car.cpp MP/Car.hpp MP/Truck.cpp MP/Truck.hpp MP/Logger.cpp MP/Logger.hpp MP/main.cpp) -add_executable(08_PTRN_Testat Testat/main.cpp Testat/Money.cpp Testat/Money.h Testat/Currency.h Testat/BankAccount.cpp Testat/BankAccount.h Testat/Cash.cpp Testat/Cash.h Testat/Currency.cpp Testat/Coin.cpp Testat/Coin.h Testat/Bill.cpp Testat/Bill.h Testat/CashFactory.cpp Testat/CashFactory.h Testat/Person.cpp Testat/Person.h) \ No newline at end of file +add_executable(08_PTRN_Testat Testat/main.cpp Testat/Money.cpp Testat/Money.h Testat/Currency.h Testat/BankAccount.cpp Testat/BankAccount.h Testat/Cash.cpp Testat/Cash.h Testat/Currency.cpp Testat/Coin.cpp Testat/Coin.h Testat/Bill.cpp Testat/Bill.h Testat/CashFactory.h Testat/Person.cpp Testat/Person.h Testat/CashFactory.cpp) \ No newline at end of file diff --git a/src/08_PTRN/Testat/CashFactory.cpp b/src/08_PTRN/Testat/CashFactory.cpp index 669bf26..9550403 100644 --- a/src/08_PTRN/Testat/CashFactory.cpp +++ b/src/08_PTRN/Testat/CashFactory.cpp @@ -1,9 +1,8 @@ #include -#include #include "CashFactory.h" int allowedBills[5] = {100, 50, 20, 10, 5}; -int allowedCoins[8] = {1, 2, 5, 10, 20, 50, 100, 200}; +int allowedCoins[9] = {1, 2, 5, 10, 20, 50, 100, 200, 300}; Bill * CashFactory::printBill(int value, Currency currency) { auto * iter = std::find(std::begin(allowedBills), std::end(allowedBills), value); @@ -11,10 +10,6 @@ Bill * CashFactory::printBill(int value, Currency currency) { return nullptr; }else { std::string serial = randomString(15); - while(std::find(usedSerials.begin(), usedSerials.end(), serial) != usedSerials.end()) { - serial = randomString(15); - } - usedSerials.push_back(serial); return new Bill(value, currency, serial); } } @@ -30,8 +25,8 @@ std::string CashFactory::randomString(size_t length) { auto randchar = []() -> char { const char charset[] = "0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz"; + "ABCDEFGHIKLMNOPRSTUVWXYZ" + "abcdfghijklmnoqrstuvwxyz"; const size_t max_index = (sizeof(charset) - 1); return charset[rand() % max_index]; }; @@ -39,4 +34,4 @@ std::string CashFactory::randomString(size_t length) { std::generate_n(str.begin(), length, randchar); return str; -} +} \ No newline at end of file diff --git a/src/08_PTRN/Testat/CashFactory.h b/src/08_PTRN/Testat/CashFactory.h index a133672..59b33b0 100644 --- a/src/08_PTRN/Testat/CashFactory.h +++ b/src/08_PTRN/Testat/CashFactory.h @@ -8,12 +8,10 @@ class CashFactory { private: - std::vector usedSerials; std::string randomString(size_t length); public: Bill * printBill(int value, Currency currency); Coin * printCoin(int value, Currency currency); }; - -#endif +#endif \ No newline at end of file