diff --git a/.gitignore b/.gitignore index a5b0124..df2113c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +bin +obj + # Compiled Object files *.slo *.lo diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..fc8853c --- /dev/null +++ b/build.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/LogInSystem.cpp b/src/LogInSystem.cpp index a4038ce..5416fc9 100644 --- a/src/LogInSystem.cpp +++ b/src/LogInSystem.cpp @@ -14,12 +14,13 @@ using namespace std; LogInSystem::LogInSystem() { - + wrongPass = 0; } LogInSystem::LogInSystem(string filename) { - ifstream fin(filename); + wrongPass = 0; + ifstream fin(filename.c_str()); while (!fin.eof()) { string username; @@ -350,7 +351,7 @@ string LogInSystem::chgPhoneNo() void LogInSystem::toTxtFile(string filename) { - ofstream fout(filename); + ofstream fout(filename.c_str()); while (!users.empty()) { diff --git a/src/LogInSystem.hpp b/src/LogInSystem.hpp index 7a6616b..2fe7e8e 100644 --- a/src/LogInSystem.hpp +++ b/src/LogInSystem.hpp @@ -3,7 +3,7 @@ #include #include #include -#include "Person.cpp" +#include "Person.hpp" using namespace std; class LogInSystem @@ -24,10 +24,10 @@ public: string chgPassword(Person); string chgEmail(); string chgPhoneNo(); - void toTxtFile(); + void toTxtFile(string filename); private: vector users; - static int wrongPass = 0; - static int globalUserId; + int wrongPass; + int globalUserId; }; diff --git a/src/VehicleManager.cpp b/src/VehicleManager.cpp index 43c65f4..0713c0e 100644 --- a/src/VehicleManager.cpp +++ b/src/VehicleManager.cpp @@ -1,6 +1,9 @@ #include #include #include +#include +#include +#include #include #include "VehicleManager.hpp" using namespace std; @@ -10,16 +13,16 @@ VehicleManager::VehicleManager() } -VehicleManager::VehicleManager(string jsonFile) +VehicleManager::VehicleManager(string jsonFileName) { - ifstream jsonFile(jsonFile.c_str()); + ifstream jsonFile(jsonFileName.c_str()); Json::Reader reader; Json::Value vehicles; - ifstream json(jsonFile.c_str(), ifstream::binary); + ifstream json(jsonFileName.c_str(), ifstream::binary); - bool parseSuccess = reader.parse(json, vehicles, false); + bool parseSuccess = reader.parse(json,vehicles,false); if(parseSuccess) { @@ -68,7 +71,7 @@ VehicleManager::VehicleManager(string jsonFile) bool VehicleManager::add(Vehicle newVehicle) { - if (newVehicle.getId() <= vehicle.back().getId()) + if (newVehicle.getId() <= vehicles.back().getId()) { return false; } @@ -102,7 +105,7 @@ Vehicle VehicleManager::get(int id) } } -void VehicleManager::toJson(string jsonFile) +void VehicleManager::toJson(string jsonFileName) { Json::Value jsonLib; @@ -119,21 +122,22 @@ void VehicleManager::toJson(string jsonFile) jsonVehicle["DateNTime"] = vehicle.getDateNTime(); jsonVehicle["id"] = vehicle.getId(); - int* seatMap = new int[vehicle.getLength()][vehicle.getWidth()]; + Json::Value seatMap; for (int i = 0; i < vehicle.getLength(); i++) { + Json::Value row; for (int j = 0; j < vehicle.getWidth(); j++) { - seatMap[i][j] = vehicle.getGuest(i, y); + row.append(vehicle.getGuest(i, j)); } + seatMap.append(row); } - jsonVehicle["SeatMap"] = seatMap; } Json::StyledStreamWriter ssw(" "); - ofstream jsonOutFile(jsonFile.c_str(), ofstream::binary); + ofstream jsonOutFile(jsonFileName.c_str(), ofstream::binary); ssw.write(jsonOutFile, jsonLib); } diff --git a/src/VehicleManager.hpp b/src/VehicleManager.hpp index 5d9089d..65a4e38 100644 --- a/src/VehicleManager.hpp +++ b/src/VehicleManager.hpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include "Vehicle.hpp" using namespace std; @@ -10,10 +12,10 @@ private: public: VehicleManager(); - VehicleManager(string jsonFile); + VehicleManager(string jsonFileName); bool add(Vehicle newVehicle); bool remove(Vehicle toRemove); Vehicle get(int id); - void toJson(string jsonFile); + void toJson(string jsonFileName); int getId(); -} +}; diff --git a/src/main.cpp b/src/main.cpp index 50b5f86..7f127b4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,9 +2,8 @@ #include #include #include -#include "VehicleManager.cpp" -#include "LogInSystem.cpp" -#include "Person.cpp" +#include "VehicleManager.hpp" +#include "LogInSystem.hpp" using namespace std; int main()