diff --git a/LogInSystem.cpp b/LogInSystem.cpp index 3e7bdff..2fc1a89 100644 --- a/LogInSystem.cpp +++ b/LogInSystem.cpp @@ -6,9 +6,11 @@ #include #include +#include #include #include #include "Person.cpp" +#include "Vehicle.cpp" using namespace std; //Declaration of functions @@ -24,9 +26,10 @@ string chgPassword(Person); string chgEmail(); string chgPhoneNo(); +vector vehicles; vector users; static int wrongPass = 0; -static int globalId; +static int globalUserId; int main() { @@ -46,8 +49,43 @@ int main() } users.pop_back(); + globalUserId = users.back().getId() + 1; + +/* + ifstream otherFin("vehiclesData.txt"); + + while (!otherFin.eof()) + { + string type; + int length; + int width; + string origin; + string destination; + string dateNtime; + int id; + otherFin >> type >> length >> width >> origin >> destination >> dateNtime >> id; + + vector< vector > seatMap; + + for (int i = 0; i < length; i++) + { + vector row; + for (int j = 0; j < width; j++) + { + int temp; + otherFin >> temp; + row.push_back(temp); + } + seatMap.push_back(row); + } + + Vehicle newVehicle(type, length, width, origin, destination, dateNtime, id, seatMap); + vehicles.push_back(newVehicle); + } + + vehicles.pop_back(); +*/ - globalId = users.back().getId() + 1; int userOption = -1; while (userOption != 0) @@ -114,7 +152,7 @@ Person getUser(int toSearchId) bool login() { - Person currentUser; + Person currentUser(-1); string username; string password; //If the user already has 3 fail attempt to login @@ -213,10 +251,10 @@ Person registration() cin >> phoneNo; //Create and push the new 'Person' into stack - Person newUser(username, password, email, phoneNo, globalId); + Person newUser(username, password, email, phoneNo, globalUserId); users.push_back(newUser); - globalId++; + globalUserId++; //Print success message cout << "Account is successfully registered." << endl; diff --git a/Vehicle.cpp b/Vehicle.cpp index 0af65c4..0d50c9c 100644 --- a/Vehicle.cpp +++ b/Vehicle.cpp @@ -4,6 +4,10 @@ using namespace std; Vehicle::Vehicle(int length, int width, int id) { + type = "TBA"; + origin = "TBA"; + destination = "TBA"; + dateNtime = "TBA"; this->length = length; this->width = width; this->id = id; @@ -22,6 +26,18 @@ Vehicle::Vehicle(string type, int length, int width, string origin, string desti initialize(); } +Vehicle::Vehicle(string type, int length, int width, string origin, string destination, string dateNtime, int id, vector< vector > seatMap) +{ + this->type = type; + this->length = length; + this->width = width; + this->origin = origin; + this->destination = destination; + this->dateNtime = dateNtime; + this->id = id; + this->seatMap = seatMap; +} + void Vehicle::setType(string type) { this->type = type; diff --git a/Vehicle.hpp b/Vehicle.hpp index ddadcaa..007abb9 100644 --- a/Vehicle.hpp +++ b/Vehicle.hpp @@ -18,6 +18,7 @@ private: public: Vehicle(int length, int width, int id); Vehicle(string type, int length, int width, string origin, string destination, string dateNtime, int id); + Vehicle(string type, int length, int width, string origin, string destination, string dateNtime, int id, vector< vector > seatMap); void setType(string type); void setLength(int length); void setWidth(int width); diff --git a/VehicleManager.cpp b/VehicleManager.cpp new file mode 100644 index 0000000..492d5f6 --- /dev/null +++ b/VehicleManager.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include "VehicleManager.hpp" +using namespace std; + +VehicleManager::VehicleManager() +{ + +} + +VehicleManager::VehicleManager(string jsonFile) +{ + ifstream jsonFile(jsonFile.c_str()); + + Json::Reader reader; + Json::Value vehicle; + + ifstream json(jsonFile.c_str(), ifstream::binary); + + bool parseSuccess = reader.parse(json, vehicle, false); + + if(parseSuccess) + { + + } +} diff --git a/VehicleManager.hpp b/VehicleManager.hpp new file mode 100644 index 0000000..41a2976 --- /dev/null +++ b/VehicleManager.hpp @@ -0,0 +1,18 @@ +#include +#include +#include "Vehicle.hpp" +using namespace std; + +class VehicleManager +{ +private: + vector vehicles; + +public: + VehicleManager(); + VehicleManager(string jsonFile); + bool add(Vehicle newVehicle); + bool remove(Vehicle toRemove); + Vehicle get(int id); + void toJson(string jsonFile); +} diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..299694a --- /dev/null +++ b/main.cpp @@ -0,0 +1,17 @@ +#include +#include +#include +#include +#include "VehicleManager.cpp" +using namespace std; + +int main() +{ + Vehicle test = Vehicle(10, 5, 0); + + if (test.bookSeat(3, 4, 10)) + { + cout << "Booking success" << endl; + } + test.printMap(10); +} diff --git a/vehiclesData.txt b/vehiclesData.txt new file mode 100644 index 0000000..e69de29