feat: add file-based persistence and restore full app state

- implement FileDatabase<T> for loading and saving objects
- add serialize / deserialize methods to all model classes
- add foreign key relationships among classes alongside object ownership
- replace object references and usernames with persistent IDs
- replace users map from username key to userId key
- load full state on startup and persist state on shutdown
- re-link users, restaurants, menu items, orders, items, and assignments after load
- fix: add order to controller m_orders
- refactor: store shared pointer to MenuItem in Item, not a reference
- refactor: store shared pointer to Order in DeliveryAssignment
- refactor: remove customer username from Order
- add initial snapshot files for users, restaurants, and menu items
- add empty snapshot files for remaining persisted entities
This commit is contained in:
Joel Thomas
2026-02-23 00:51:40 +05:30
parent 6f12328ed5
commit 7d51eeccdf
26 changed files with 1026 additions and 65 deletions
@@ -24,6 +24,15 @@ public:
const std::string& email, const std::string& email,
const std::string& address) : const std::string& address) :
User(username, name, phone, password, email, address) User(username, name, phone, password, email, address)
{}
Customer(int id,
const std::string& username,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& address) :
User(id, username, name, phone, password, email, address)
{} {}
void addOrder(std::shared_ptr<Order>); void addOrder(std::shared_ptr<Order>);
orders& getOrders(); orders& getOrders();
@@ -3,8 +3,21 @@ Author: Joel Mathew Thomas
Date: 18-02-2026 Date: 18-02-2026
*/ */
#include <sstream>
#include "DeliveryAssignment.h" #include "DeliveryAssignment.h"
DeliveryAssignment::DeliveryAssignment(int id, DeliveryStatus status, int orderId, int deliveryPartnerId) :
m_id(id),
m_status(status),
m_orderId(orderId),
m_deliveryPartnerId(deliveryPartnerId)
{
if (id > m_uid)
{
m_uid = id;
}
}
int DeliveryAssignment::m_uid = 0; int DeliveryAssignment::m_uid = 0;
int DeliveryAssignment::getId() const int DeliveryAssignment::getId() const
@@ -22,7 +35,85 @@ void DeliveryAssignment::setStatus(const DeliveryStatus& status)
m_status = status; m_status = status;
} }
Order& DeliveryAssignment::getOrder() std::shared_ptr<Order> DeliveryAssignment::getOrder()
{ {
return m_order; return m_order;
} }
void DeliveryAssignment::setOrder(std::shared_ptr<Order> order)
{
m_order = order;
}
int DeliveryAssignment::getDeliveryPartnerId() const
{
return m_deliveryPartnerId;
}
void DeliveryAssignment:: setDeliveryPartnerId(int deliveryPartnerId)
{
m_deliveryPartnerId = deliveryPartnerId;
}
int DeliveryAssignment::getOrderId() const
{
return m_orderId;
}
std::string DeliveryAssignment::serialize() const
{
std::ostringstream serializedDeliveryAssignment;
serializedDeliveryAssignment << m_id << '|'
<< static_cast<int>(m_status) << '|'
<< m_orderId << '|'
<< m_deliveryPartnerId;
return serializedDeliveryAssignment.str();
}
std::shared_ptr<DeliveryAssignment> DeliveryAssignment::deserialize(const std::string& record)
{
int id, orderId, deliveryPartnerId;
DeliveryStatus status;
std::string token;
std::istringstream serializedDeliveryAssignment(record);
getline(serializedDeliveryAssignment, token, '|');
try {
id = std::stoi(token);
}
catch (...)
{
throw std::runtime_error("Invalid DeliveryAssignment ID in snapshot");
}
getline(serializedDeliveryAssignment, token, '|');
int statusInt = std::stoi(token);
if (statusInt < static_cast<int>(DeliveryStatus::CREATED) ||
statusInt > static_cast<int>(DeliveryStatus::DELIVERED))
{
throw std::runtime_error("Invalid DeliveryStatus for DeliveryAssignment in snapshot");
}
status = static_cast<DeliveryStatus>(statusInt);
getline(serializedDeliveryAssignment, token, '|');
try {
orderId = std::stoi(token);
}
catch (...)
{
throw std::runtime_error("Invalid Order ID for DeliveryAssignment in snapshot");
}
getline(serializedDeliveryAssignment, token, '|');
try {
deliveryPartnerId = std::stoi(token);
}
catch (...)
{
throw std::runtime_error("Invalid DeliveryPartner ID for DeliveryAssignment in snapshot");
}
if (status == DeliveryStatus::CREATED)
{
return std::make_shared<DeliveryAssignment>(id, status, orderId, 0);
}
else
{
return std::make_shared<DeliveryAssignment>(id, status, orderId, deliveryPartnerId);
}
}
@@ -4,6 +4,7 @@ Date: 18-12-2026
*/ */
#pragma once #pragma once
#include <memory>
#include "Order.h" #include "Order.h"
enum class DeliveryStatus enum class DeliveryStatus
@@ -18,17 +19,34 @@ class DeliveryAssignment
private: private:
static int m_uid; static int m_uid;
int m_id; int m_id;
Order& m_order; std::shared_ptr<Order> m_order;
DeliveryStatus m_status; DeliveryStatus m_status;
int m_orderId;
int m_deliveryPartnerId;
public: public:
DeliveryAssignment(Order& order) : DeliveryAssignment() :
m_id(++m_uid),
m_status(DeliveryStatus::CREATED),
m_orderId(0),
m_deliveryPartnerId(0)
{}
DeliveryAssignment(std::shared_ptr<Order> order, int orderId) :
m_id(++m_uid), m_id(++m_uid),
m_order(order), m_order(order),
m_status(DeliveryStatus::CREATED) m_status(DeliveryStatus::CREATED),
m_orderId(orderId),
m_deliveryPartnerId(0)
{} {}
int getId() const; int getId() const;
DeliveryStatus getStatus() const; DeliveryStatus getStatus() const;
void setStatus(const DeliveryStatus&); void setStatus(const DeliveryStatus&);
Order& getOrder(); std::shared_ptr<Order> getOrder();
void setOrder(std::shared_ptr<Order>);
int getDeliveryPartnerId() const;
void setDeliveryPartnerId(int);
int getOrderId() const;
std::string serialize() const;
static std::shared_ptr<DeliveryAssignment> deserialize(const std::string&);
DeliveryAssignment(int, DeliveryStatus, int, int);
}; };
@@ -24,6 +24,15 @@ public:
const std::string& email, const std::string& email,
const std::string& address) : const std::string& address) :
User(username, name, phone, password, email, address) User(username, name, phone, password, email, address)
{}
DeliveryPartner(int id,
const std::string& username,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& address) :
User(id, username, name, phone, password, email, address)
{} {}
void acceptDeliveryAssignment(std::shared_ptr<DeliveryAssignment>); void acceptDeliveryAssignment(std::shared_ptr<DeliveryAssignment>);
deliveryAssignments& getAssignedDeliveries(); deliveryAssignments& getAssignedDeliveries();
@@ -1,5 +1,55 @@
/*
Author: Joel Mathew Thomas
Date: 22-12-2026
*/
#pragma once #pragma once
#include<iostream>
#include<memory>
#include<map>
#include<fstream>
#include<string>
#include<stdexcept>
template <typename T> using objects = std::map<int, std::shared_ptr<T>>;
template <typename T>
class FileDatabase class FileDatabase
{ {
private:
std::string m_filePath;
public:
FileDatabase() : m_filePath("") {}
FileDatabase(const std::string& filePath) : m_filePath(filePath) {}
objects<T> load();
void save(const objects<T>&);
}; };
template <typename T>
objects<T> FileDatabase<T>::load()
{
objects<T> records;
std::ifstream file(m_filePath);
if (!file.is_open())
throw std::runtime_error("Failed to open file " + m_filePath);
std::string record;
while (std::getline(file, record))
{
auto object = T::deserialize(record);
records[object->getId()] = object;
}
return records;
}
template <typename T>
void FileDatabase<T>::save(const objects<T>& records)
{
std::ofstream file(m_filePath, std::ios::trunc);
if (!file.is_open())
throw std::runtime_error("Failed to open file " + m_filePath);
for (const auto& recordPair : records)
{
file << recordPair.second->serialize() << '\n';
}
}
@@ -20,6 +20,7 @@ Date: 19-02-2026
#include "DeliveryAssignment.h" #include "DeliveryAssignment.h"
#include "inputHelper.h" #include "inputHelper.h"
#include "outputHelper.h" #include "outputHelper.h"
#include "FileDatabase.h"
static bool checkAccess(std::shared_ptr<User> user, const std::string& userWithAccess) static bool checkAccess(std::shared_ptr<User> user, const std::string& userWithAccess)
{ {
@@ -37,7 +38,7 @@ static restaurants::iterator pickRestaurantFromRestaurants(restaurants& ownerRes
int restaurantIndex = 1, restaurantChoiceIndex; int restaurantIndex = 1, restaurantChoiceIndex;
if (ownerRestaurants.empty()) if (ownerRestaurants.empty())
{ {
std::cout << "You do not own any Restaurants!\n"; std::cout << "No Restaurants available!\n";
return ownerRestaurants.end(); return ownerRestaurants.end();
} }
std::cout << "Pick a Restaurant\n"; std::cout << "Pick a Restaurant\n";
@@ -197,8 +198,8 @@ static deliveryAssignments::iterator pickAssignmentFromDeliveryAssignments(deliv
<< "\n"; << "\n";
for (auto& assignment : assignments) for (auto& assignment : assignments)
{ {
Order& order = assignment.second->getOrder(); Order& order = *(assignment.second->getOrder());
users::const_iterator customer = allUsers.find(order.getCustomerUsername()); users::const_iterator customer = allUsers.find(order.getCustomerId());
if (customer == allUsers.end()) if (customer == allUsers.end())
{ {
throw std::runtime_error("Invalid state: Delivery Assignment has no associated Customer."); throw std::runtime_error("Invalid state: Delivery Assignment has no associated Customer.");
@@ -223,9 +224,159 @@ static deliveryAssignments::iterator pickAssignmentFromDeliveryAssignments(deliv
return assignmentIterator; return assignmentIterator;
} }
void FoodDeliveryController::loadStates()
{
FileDatabase<User> userDatabase("users.txt");
FileDatabase<Restaurant> restaurantDatabase("restaurants.txt");
FileDatabase<MenuItem> menuItemDatabase("menuItems.txt");
FileDatabase<Order> orderDatabase("orders.txt");
FileDatabase<Item> itemDatabase("items.txt");
FileDatabase<DeliveryAssignment> deliveryAssignmentsDatabase("assignments.txt");
objects<MenuItem> menuItems;
objects<Item> items;
m_users = userDatabase.load();
m_restaurants = restaurantDatabase.load();
for (const auto& restaurantPair : m_restaurants)
{
Restaurant& restaurant = *(restaurantPair.second);
int ownerId = restaurant.getOwnerId();
auto userIterator = m_users.find(ownerId);
if (userIterator == m_users.end())
throw std::runtime_error("Restaurant has invalid owner ID");
auto owner = std::dynamic_pointer_cast<RestaurantOwner>(userIterator->second);
if (!owner)
{
throw std::runtime_error("Restaurant owner is not a RestaurantOwner");
}
owner->addRestaurant(restaurantPair.second);
}
menuItems = menuItemDatabase.load();
for (auto& menuItemPair : menuItems)
{
auto restaurantIterator = m_restaurants.find(menuItemPair.second->getRestaurantId());
if (restaurantIterator != m_restaurants.end())
{
restaurantIterator->second->addMenuItem(*(menuItemPair.second));
}
else
{
throw std::runtime_error("MenuItem has invalid Restaurant ID");
}
}
m_orders = orderDatabase.load();
for (auto& orderPair : m_orders)
{
int customerId = orderPair.second->getCustomerId();
int restaurantId = orderPair.second->getRestaurantId();
auto customerIterator = m_users.find(customerId);
if (customerIterator == m_users.end())
{
throw std::runtime_error("Order has invalid customer ID");
}
auto customer = std::dynamic_pointer_cast<Customer>(customerIterator->second);
if (!customer)
{
throw std::runtime_error("User associated with Order is not a Customer");
}
customer->addOrder(orderPair.second);
auto restaurantIterator = m_restaurants.find(restaurantId);
if (restaurantIterator == m_restaurants.end())
{
throw std::runtime_error("Order has invalid restaurant ID");
}
restaurantIterator->second->addOrder(orderPair.second);
}
items = itemDatabase.load();
for (auto& itemPair : items)
{
int itemId = itemPair.second->getMenuItemId();
auto menuItemiterator = menuItems.find(itemId);
if (menuItemiterator != menuItems.end())
{
itemPair.second->setMenuItem(menuItemiterator->second);
}
else
{
throw std::runtime_error("Item has invalid MenuItem ID");
}
int orderId = itemPair.second->getOrderId();
auto orderIterator = m_orders.find(orderId);
if (orderIterator != m_orders.end())
{
orderIterator->second->addItem(*(itemPair.second));
}
else
{
throw std::runtime_error("Item has invalid Order ID");
}
}
m_assignments = deliveryAssignmentsDatabase.load();
for (auto& assignmentPair : m_assignments)
{
int orderId = assignmentPair.second->getOrderId();
int deliveryPartnerId = assignmentPair.second->getDeliveryPartnerId();
auto orderIterator = m_orders.find(orderId);
if (orderIterator != m_orders.end())
{
assignmentPair.second->setOrder(orderIterator->second);
}
else
{
throw std::runtime_error("Delivery Assignment has invalid Order ID");
}
if (deliveryPartnerId != 0)
{
auto userIterator = m_users.find(deliveryPartnerId);
if (userIterator == m_users.end())
{
throw std::runtime_error("Order has invalid Delivery Partner ID");
}
auto deliveryPartner = std::dynamic_pointer_cast<DeliveryPartner>(userIterator->second);
if (!deliveryPartner)
{
throw std::runtime_error("User associated with Order is not a Delivery Partner");
}
deliveryPartner->acceptDeliveryAssignment(assignmentPair.second);
}
}
}
void FoodDeliveryController::persistStates()
{
FileDatabase<User> userDatabase("users.txt");
FileDatabase<Restaurant> restaurantDatabase("restaurants.txt");
FileDatabase<MenuItem> menuItemDatabase("menuItems.txt");
FileDatabase<Order> orderDatabase("orders.txt");
FileDatabase<Item> itemDatabase("items.txt");
FileDatabase<DeliveryAssignment> deliveryAssignmentsDatabase("assignments.txt");
userDatabase.save(m_users);
restaurantDatabase.save(m_restaurants);
objects<MenuItem> allMenuItems;
objects<Item> allItems;
for (const auto& restaurantPair : m_restaurants)
{
for (const auto& menuItemPair : restaurantPair.second->getMenuItems())
{
allMenuItems[menuItemPair.first] = menuItemPair.second;
}
}
menuItemDatabase.save(allMenuItems);
orderDatabase.save(m_orders);
for (const auto& orderPair : m_orders)
{
for (const auto& item : orderPair.second->getItems())
{
allItems[item->getId()] = item;
}
}
itemDatabase.save(allItems);
deliveryAssignmentsDatabase.save(m_assignments);
}
void FoodDeliveryController::run() void FoodDeliveryController::run()
{ {
bool isMenuActive = true; bool isMenuActive = true;
loadStates();
while (isMenuActive) while (isMenuActive)
{ {
int choice; int choice;
@@ -262,17 +413,25 @@ void FoodDeliveryController::run()
util::pressEnter(); util::pressEnter();
} }
} }
persistStates();
} }
void FoodDeliveryController::login() void FoodDeliveryController::login()
{ {
util::clear(); util::clear();
std::string username, password; std::string username, password;
std::cout << "Enter username: ";; std::cout << "Enter username: ";
util::readString(username); util::readString(username);
std::cout << "Enter password: ";; std::cout << "Enter password: ";
util::readString(password); util::readString(password);
users::iterator userIterator = m_users.find(username); users::iterator userIterator = std::find_if(
m_users.begin(),
m_users.end(),
[&username](const auto& pair)
{
return pair.second->getUsername() == username;
}
);
if (userIterator != m_users.end()) if (userIterator != m_users.end())
{ {
User& user = *(userIterator->second); User& user = *(userIterator->second);
@@ -318,7 +477,15 @@ void FoodDeliveryController::registerUser()
util::clear(); util::clear();
std::cout << "Enter Username: "; std::cout << "Enter Username: ";
util::readString(username); util::readString(username);
if (m_users.find(username) != m_users.end()) users::iterator userIterator = std::find_if(
m_users.begin(),
m_users.end(),
[&username](const auto& pair)
{
return pair.second->getUsername() == username;
}
);
if (userIterator != m_users.end())
{ {
std::cout << "User Already Exists!\n"; std::cout << "User Already Exists!\n";
return; return;
@@ -343,23 +510,29 @@ void FoodDeliveryController::registerUser()
"4. Cancel\n" "4. Cancel\n"
"Choice?: "; "Choice?: ";
util::readValue<int>(choice); util::readValue<int>(choice);
switch (choice) if (choice == 1)
{
std::shared_ptr<User> user = std::make_shared<RestaurantOwner>(username, name, phone, password, email, address);
m_users[user->getId()] = user;
}
else if (choice == 2)
{
std::shared_ptr<User> user = std::make_shared<Customer>(username, name, phone, password, email, address);
m_users[user->getId()] = user;
}
else if (choice == 3)
{
std::shared_ptr<User> user = std::make_shared<DeliveryPartner>(username, name, phone, password, email, address);
m_users[user->getId()] = user;
}
else if (choice == 4)
{ {
case 1:
m_users[username] = std::make_shared<RestaurantOwner>(username, name, phone, password, email, address);
break;
case 2:
m_users[username] = std::make_shared<Customer>(username, name, phone, password, email, address);
break;
case 3:
m_users[username] = std::make_shared<DeliveryPartner>(username, name, phone, password, email, address);
break;
case 4:
return; return;
default: }
else
{
util::clear(); util::clear();
std::cout << "Invalid Choice! Try Again\n"; std::cout << "Invalid Choice! Try Again\n";
continue;
} }
break; break;
} }
@@ -411,7 +584,7 @@ void FoodDeliveryController::addNewRestaurant()
RestaurantOwner& restaurantOwner = *(std::dynamic_pointer_cast<RestaurantOwner>(m_authenticatedUser)); RestaurantOwner& restaurantOwner = *(std::dynamic_pointer_cast<RestaurantOwner>(m_authenticatedUser));
std::cout << "Enter Restaurant Name: "; std::cout << "Enter Restaurant Name: ";
util::readString(name); util::readString(name);
std::shared_ptr<Restaurant> restaurant = std::make_shared<Restaurant>(name); std::shared_ptr<Restaurant> restaurant = std::make_shared<Restaurant>(name, restaurantOwner.getId());
m_restaurants[restaurant->getId()] = restaurant; m_restaurants[restaurant->getId()] = restaurant;
restaurantOwner.addRestaurant(restaurant); restaurantOwner.addRestaurant(restaurant);
std::cout << "Restaurant " << restaurant->getName() << " with ID " << restaurant->getId() << " created successfully\n"; std::cout << "Restaurant " << restaurant->getName() << " with ID " << restaurant->getId() << " created successfully\n";
@@ -489,7 +662,7 @@ void FoodDeliveryController::listRestaurantOrders() const
<< "\n"; << "\n";
for (auto& item : orderItems) for (auto& item : orderItems)
{ {
MenuItem& menuItem = item->getMenuItem(); MenuItem& menuItem = *(item->getMenuItem());
std::cout << std::left << std::setw(25) << menuItem.getName() std::cout << std::left << std::setw(25) << menuItem.getName()
<< std::left << std::setw(10) << menuItem.getPrice() << std::left << std::setw(10) << menuItem.getPrice()
<< std::left << std::setw(10) << item->getQuantity() << std::left << std::setw(10) << item->getQuantity()
@@ -542,7 +715,7 @@ void FoodDeliveryController::markOrderReady()
if (orderStatus == OrderStatus::CREATED) if (orderStatus == OrderStatus::CREATED)
{ {
orderIterator->second->setStatus(OrderStatus::READYFORPICKUP); orderIterator->second->setStatus(OrderStatus::READYFORPICKUP);
std::shared_ptr<DeliveryAssignment> deliveryAssignment = std::make_shared<DeliveryAssignment>(*orderIterator->second); std::shared_ptr<DeliveryAssignment> deliveryAssignment = std::make_shared<DeliveryAssignment>(orderIterator->second, orderIterator->second->getId());
m_assignments[deliveryAssignment->getId()] = deliveryAssignment; m_assignments[deliveryAssignment->getId()] = deliveryAssignment;
std::cout << "Order has been marked ready for pickup\n"; std::cout << "Order has been marked ready for pickup\n";
} }
@@ -638,7 +811,7 @@ void FoodDeliveryController::addMenuItem() const
util::readString(description); util::readString(description);
std::cout << "Enter Item Price: "; std::cout << "Enter Item Price: ";
util::readValue<double>(price); util::readValue<double>(price);
MenuItem menuItem(name, description, price); MenuItem menuItem(name, description, price, restaurantIterator->second->getId());
restaurantIterator->second->addMenuItem(menuItem); restaurantIterator->second->addMenuItem(menuItem);
std::cout << "Added new Menu Item " << menuItem.getName() << " with ID " << menuItem.getId() << " to Restaurant " << restaurantIterator->second->getName() << " successfully\n"; std::cout << "Added new Menu Item " << menuItem.getName() << " with ID " << menuItem.getId() << " to Restaurant " << restaurantIterator->second->getName() << " successfully\n";
} }
@@ -728,7 +901,7 @@ void FoodDeliveryController::listCustomerOrders() const
<< "\n"; << "\n";
for (auto& item : orderItems) for (auto& item : orderItems)
{ {
MenuItem& menuItem = item->getMenuItem(); MenuItem& menuItem = *(item->getMenuItem());
std::cout << std::left << std::setw(25) << menuItem.getName() std::cout << std::left << std::setw(25) << menuItem.getName()
<< std::left << std::setw(10) << menuItem.getPrice() << std::left << std::setw(10) << menuItem.getPrice()
<< std::left << std::setw(10) << item->getQuantity() << std::left << std::setw(10) << item->getQuantity()
@@ -794,9 +967,9 @@ void FoodDeliveryController::placeOrder()
{ {
if (!order) if (!order)
{ {
order = std::make_shared<Order>(customer->getName()); order = std::make_shared<Order>(restaurantIterator->second->getId(), customer->getId());
} }
order->addItem(Item(*(menuItemIterator->second), quantity)); order->addItem(Item(menuItemIterator->second, menuItemIterator->second->getId(), quantity, order->getId()));
std::cout << menuItemIterator->second->getName() << " with quantity " << quantity << " has been added to your Order\n"; std::cout << menuItemIterator->second->getName() << " with quantity " << quantity << " has been added to your Order\n";
} }
else else
@@ -820,6 +993,7 @@ void FoodDeliveryController::placeOrder()
{ {
customer->addOrder(order); customer->addOrder(order);
restaurantIterator->second->addOrder(order); restaurantIterator->second->addOrder(order);
m_orders[order->getId()] = order;
std::cout << "Order with ID " << order->getId() << " has been placed successfully\n"; std::cout << "Order with ID " << order->getId() << " has been placed successfully\n";
} }
else else
@@ -912,8 +1086,8 @@ void FoodDeliveryController::listDeliveryAssignments()
<< "\n"; << "\n";
for (auto& assignment : assignments) for (auto& assignment : assignments)
{ {
Order& order = assignment.second->getOrder(); Order& order = *(assignment.second->getOrder());
users::const_iterator customer = m_users.find(order.getCustomerUsername()); users::const_iterator customer = m_users.find(order.getCustomerId());
if (customer == m_users.end()) if (customer == m_users.end())
{ {
throw std::runtime_error("Invalid state: Delivery Assignment has no associated Customer."); throw std::runtime_error("Invalid state: Delivery Assignment has no associated Customer.");
@@ -957,7 +1131,8 @@ void FoodDeliveryController::acceptDeliveryAssignment()
if (deliveryStatus == DeliveryStatus::CREATED) if (deliveryStatus == DeliveryStatus::CREATED)
{ {
assignmentIterator->second->setStatus(DeliveryStatus::ACCEPTED); assignmentIterator->second->setStatus(DeliveryStatus::ACCEPTED);
assignmentIterator->second->getOrder().setStatus(OrderStatus::OUTFORDELIVERY); assignmentIterator->second->setDeliveryPartnerId(deliveryPartner->getId());
assignmentIterator->second->getOrder()->setStatus(OrderStatus::OUTFORDELIVERY);
deliveryPartner->acceptDeliveryAssignment(assignmentIterator->second); deliveryPartner->acceptDeliveryAssignment(assignmentIterator->second);
std::cout << "Delivery Assignment " << assignmentIterator->second->getId() << " has been accepted successfully!\n"; std::cout << "Delivery Assignment " << assignmentIterator->second->getId() << " has been accepted successfully!\n";
} }
@@ -977,9 +1152,8 @@ void FoodDeliveryController::acceptDeliveryAssignment()
} }
} }
void FoodDeliveryController::confirmDeliveryAssignment() void FoodDeliveryController::confirmDeliveryAssignment() const
{ {
try try
{ {
util::clear(); util::clear();
@@ -1005,7 +1179,7 @@ void FoodDeliveryController::confirmDeliveryAssignment()
if (deliveryStatus == DeliveryStatus::ACCEPTED) if (deliveryStatus == DeliveryStatus::ACCEPTED)
{ {
assignmentIterator->second->setStatus(DeliveryStatus::DELIVERED); assignmentIterator->second->setStatus(DeliveryStatus::DELIVERED);
assignmentIterator->second->getOrder().setStatus(OrderStatus::DELIVERED); assignmentIterator->second->getOrder()->setStatus(OrderStatus::DELIVERED);
std::cout << "Delivery Assignment " << assignmentIterator->second->getId() << " has been completed successfully!\n"; std::cout << "Delivery Assignment " << assignmentIterator->second->getId() << " has been completed successfully!\n";
} }
else else
@@ -1030,7 +1204,8 @@ void FoodDeliveryController::viewProfile() const
{ {
util::clear(); util::clear();
std::cout << "My Profile\n"; std::cout << "My Profile\n";
std::cout << std::left << std::setw(10) << "Name " << ": " << m_authenticatedUser->getName() << "\n" std::cout << std::left << std::setw(10) << "ID " << ": " << m_authenticatedUser->getId() << "\n"
<< std::setw(10) << "Name " << ": " << m_authenticatedUser->getName() << "\n"
<< std::left << std::setw(10) << "Username " << ": " << m_authenticatedUser->getUsername() << "\n" << std::left << std::setw(10) << "Username " << ": " << m_authenticatedUser->getUsername() << "\n"
<< std::left << std::setw(10) << "Phone " << ": " << m_authenticatedUser->getPhone() << "\n" << std::left << std::setw(10) << "Phone " << ": " << m_authenticatedUser->getPhone() << "\n"
<< std::left << std::setw(10) << "Email " << ": " << m_authenticatedUser->getEmail() << "\n" << std::left << std::setw(10) << "Email " << ": " << m_authenticatedUser->getEmail() << "\n"
@@ -16,7 +16,7 @@ class Item;
class Order; class Order;
class DeliveryAssignment; class DeliveryAssignment;
using users = std::map<std::string, std::shared_ptr<User>>; using users = std::map<int, std::shared_ptr<User>>;
using restaurants = std::map<int, std::shared_ptr<Restaurant>>; using restaurants = std::map<int, std::shared_ptr<Restaurant>>;
using menuItems = std::map<int, std::shared_ptr<MenuItem>>; using menuItems = std::map<int, std::shared_ptr<MenuItem>>;
using items = std::vector<std::shared_ptr<Item>>; using items = std::vector<std::shared_ptr<Item>>;
@@ -31,6 +31,8 @@ private:
orders m_orders; orders m_orders;
deliveryAssignments m_assignments; deliveryAssignments m_assignments;
std::shared_ptr<User> m_authenticatedUser; std::shared_ptr<User> m_authenticatedUser;
void loadStates();
void persistStates();
public: public:
void run(); void run();
void login(); void login();
@@ -48,7 +50,7 @@ public:
void cancelOrder() const; void cancelOrder() const;
void listDeliveryAssignments(); void listDeliveryAssignments();
void acceptDeliveryAssignment(); void acceptDeliveryAssignment();
void confirmDeliveryAssignment(); void confirmDeliveryAssignment() const;
void viewProfile() const; void viewProfile() const;
}; };
@@ -3,14 +3,98 @@ Author: Joel Mathew Thomas
Date: 18-02-2026 Date: 18-02-2026
*/ */
#include <sstream>
#include <string>
#include "Item.h" #include "Item.h"
Item::Item(int id, std::shared_ptr<MenuItem> item, int itemId, int quantity, int orderId)
: m_id(id), m_item(item), m_quantity(quantity), m_orderId(orderId), m_itemId(itemId)
{
if (id > m_uid)
{
m_uid = id;
}
}
int Item::m_uid = 0;
int Item::getId() const
{
return m_id;
}
int Item::getQuantity() const int Item::getQuantity() const
{ {
return m_quantity; return m_quantity;
} }
MenuItem& Item::getMenuItem() std::shared_ptr<MenuItem> Item::getMenuItem()
{ {
return m_item; return m_item;
} }
int Item::getOrderId() const
{
return m_orderId;
}
int Item::getMenuItemId() const
{
return m_itemId;
}
void Item::setMenuItem(std::shared_ptr<MenuItem> menuItem)
{
m_item = menuItem;
}
std::string Item::serialize() const
{
std::ostringstream serializedItem;
serializedItem << m_id << '|'
<< m_quantity << '|'
<< m_orderId << '|'
<< m_itemId;
return serializedItem.str();
}
std::shared_ptr<Item> Item::deserialize(const std::string& record)
{
int id, quantity, orderId, itemId;
std::string token;
std::istringstream serializedItem(record);
getline(serializedItem, token, '|');
try {
id = std::stoi(token);
}
catch (...)
{
throw std::runtime_error("Invalid Item ID in snapshot");
}
getline(serializedItem, token, '|');
try {
quantity = std::stoi(token);
}
catch (...)
{
throw std::runtime_error("Invalid Quantity in Item in snapshot");
}
getline(serializedItem, token, '|');
try {
orderId = std::stoi(token);
}
catch (...)
{
throw std::runtime_error("Invalid Order ID in Item in snapshot");
}
getline(serializedItem, token, '|');
try {
itemId = std::stoi(token);
}
catch (...)
{
throw std::runtime_error("Invalid MenuItem ID in Item in snapshot");
}
return std::make_shared<Item>(id, std::make_shared<MenuItem>(), itemId, quantity, orderId);
}
@@ -4,18 +4,29 @@ Date: 18-12-2026
*/ */
#pragma once #pragma once
#include <memory>
#include "MenuItem.h" #include "MenuItem.h"
class Item class Item
{ {
private: private:
MenuItem& m_item; static int m_uid;
int m_id;
std::shared_ptr<MenuItem> m_item;
int m_quantity; int m_quantity;
int m_orderId;
int m_itemId;
public: public:
Item(MenuItem& item, int quantity) Item() : m_id(++m_uid), m_quantity(0), m_orderId(0), m_itemId(0) {}
: m_item(item), m_quantity(quantity) Item(std::shared_ptr<MenuItem> item, int itemId, int quantity, int orderId)
{} : m_id(++m_uid), m_item(item), m_quantity(quantity), m_orderId(orderId), m_itemId(itemId) {}
Item(int, std::shared_ptr<MenuItem>, int, int, int);
int getId() const;
int getQuantity() const; int getQuantity() const;
MenuItem& getMenuItem(); std::shared_ptr<MenuItem> getMenuItem();
int getOrderId() const;
int getMenuItemId() const;
void setMenuItem(std::shared_ptr<MenuItem>);
std::string serialize() const;
static std::shared_ptr<Item> deserialize(const std::string&);
}; };
@@ -3,11 +3,26 @@ Author: Joel Mathew Thomas
Date: 18-02-2026 Date: 18-02-2026
*/ */
#include <sstream>
#include <stdexcept> #include <stdexcept>
#include "MenuItem.h" #include "MenuItem.h"
int MenuItem::m_uid = 0; int MenuItem::m_uid = 0;
MenuItem::MenuItem(int id, const std::string& name, const std::string& description, double price, int restaurantId):
m_id(id),
m_name(name),
m_description(description),
m_price(price),
m_restaurantId(restaurantId)
{
if (id > m_uid)
{
m_uid = id;
}
}
int MenuItem::getId() const int MenuItem::getId() const
{ {
return m_id; return m_id;
@@ -37,3 +52,51 @@ void MenuItem::setPrice(double price)
} }
m_price = price; m_price = price;
} }
int MenuItem::getRestaurantId() const
{
return m_restaurantId;
}
std::string MenuItem::serialize() const
{
std::ostringstream serializedMenuItem;
serializedMenuItem << m_id << '|'
<< m_name << '|'
<< m_description << '|'
<< m_price << '|'
<< m_restaurantId;
return serializedMenuItem.str();
}
std::shared_ptr<MenuItem> MenuItem::deserialize(const std::string& record)
{
int id, restaurantId;
double price;
std::string name, description, token;
std::istringstream serializedMenuItem(record);
getline(serializedMenuItem, token, '|');
try {
id = std::stoi(token);
}
catch (...) {
throw std::runtime_error("Invalid MenuItem ID in snapshot");
}
getline(serializedMenuItem, name, '|');
getline(serializedMenuItem, description, '|');
getline(serializedMenuItem, token, '|');
try {
price = std::stod(token);
}
catch (...) {
throw std::runtime_error("Invalid Price for MenuItem in snapshot");
}
getline(serializedMenuItem, token, '|');
try {
restaurantId = std::stoi(token);
}
catch (...) {
throw std::runtime_error("Invalid Restaurant ID for MenuItem in snapshot");
}
return std::make_shared<MenuItem>(id, name, description, price, restaurantId);
}
@@ -5,6 +5,7 @@ Date: 18-12-2026
#pragma once #pragma once
#include <string> #include <string>
#include <memory>
class MenuItem class MenuItem
{ {
@@ -14,23 +15,29 @@ private:
std::string m_name; std::string m_name;
std::string m_description; std::string m_description;
double m_price; double m_price;
int m_restaurantId;
public: public:
MenuItem(): MenuItem():
m_id(++m_uid), m_id(++m_uid),
m_name(""), m_name(""),
m_description(""), m_description(""),
m_price(0) m_price(0),
m_restaurantId(0)
{} {}
MenuItem(const std::string& name, const std::string& description, double price): MenuItem(const std::string& name, const std::string& description, double price, int restaurantId):
m_id(++m_uid), m_id(++m_uid),
m_name(name), m_name(name),
m_description(description), m_description(description),
m_price(price) m_price(price),
m_restaurantId(restaurantId)
{} {}
MenuItem(int, const std::string&, const std::string&, double, int);
int getId() const; int getId() const;
std::string getName() const; std::string getName() const;
std::string getDescription() const; std::string getDescription() const;
double getPrice() const; double getPrice() const;
void setPrice(double); void setPrice(double);
int getRestaurantId() const;
std::string serialize() const;
static std::shared_ptr<MenuItem> deserialize(const std::string&);
}; };
@@ -1,7 +1,27 @@
/*
Author: Joel Mathew Thomas
Date: 18-12-2026
*/
#include <sstream>
#include <stdexcept>
#include "Order.h" #include "Order.h"
int Order::m_uid = 0; int Order::m_uid = 0;
Order::Order(int id, OrderStatus status, int restaurantId,int customerId):
m_id(id),
m_status(status),
m_customerId(customerId),
m_restaurantId(restaurantId)
{
if (id > m_uid)
{
m_uid = id;
}
}
int Order::getId() const int Order::getId() const
{ {
return m_id; return m_id;
@@ -22,7 +42,7 @@ double Order::getTotal() const
double total = 0; double total = 0;
for (auto& itemPointer : m_items) for (auto& itemPointer : m_items)
{ {
total += itemPointer->getMenuItem().getPrice() * itemPointer->getQuantity(); total += itemPointer->getMenuItem()->getPrice() * itemPointer->getQuantity();
} }
return total; return total;
} }
@@ -37,7 +57,63 @@ void Order::setStatus(const OrderStatus& orderStatus)
m_status = orderStatus; m_status = orderStatus;
} }
const std::string& Order::getCustomerUsername() int Order::getCustomerId() const
{ {
return m_customerUsername; return m_customerId;
}
int Order::getRestaurantId() const
{
return m_restaurantId;
}
std::string Order::serialize() const
{
std::ostringstream serializedOrder;
serializedOrder << m_id << '|'
<< static_cast<int>(m_status) << '|'
<< m_customerId << '|'
<< m_restaurantId;
return serializedOrder.str();
}
std::shared_ptr<Order> Order::deserialize(const std::string& record)
{
int id, customerId, restaurantId;
OrderStatus status;
std::string token;
std::istringstream serializedOrder(record);
getline(serializedOrder, token, '|');
try {
id = std::stoi(token);
}
catch (...)
{
throw std::runtime_error("Invalid Order ID in snapshot");
}
getline(serializedOrder, token, '|');
int statusInt = std::stoi(token);
if (statusInt < static_cast<int>(OrderStatus::CREATED) ||
statusInt > static_cast<int>(OrderStatus::CANCELLED))
{
throw std::runtime_error("Invalid Order Status for Order in snapshot");
}
status = static_cast<OrderStatus>(statusInt);
getline(serializedOrder, token, '|');
try {
customerId = std::stoi(token);
}
catch (...)
{
throw std::runtime_error("Invalid Customer ID for Order in snapshot");
}
getline(serializedOrder, token, '|');
try {
restaurantId = std::stoi(token);
}
catch (...)
{
throw std::runtime_error("Invalid Restaurant ID for Order in snapshot");
}
return std::make_shared<Order>(id, status, restaurantId, customerId);
} }
@@ -26,22 +26,26 @@ private:
static int m_uid; static int m_uid;
int m_id; int m_id;
items m_items; items m_items;
double m_totalAmount;
OrderStatus m_status; OrderStatus m_status;
std::string m_customerUsername; int m_customerId;
int m_restaurantId;
public: public:
Order(const std::string& customerUsername) : Order(int restaurantId, int customerId) :
m_id(++m_uid), m_id(++m_uid),
m_totalAmount(0),
m_status(OrderStatus::CREATED), m_status(OrderStatus::CREATED),
m_customerUsername(customerUsername) m_customerId(customerId),
m_restaurantId(restaurantId)
{} {}
Order(int, OrderStatus, int, int);
int getId() const; int getId() const;
void addItem(const Item&); void addItem(const Item&);
items& getItems(); items& getItems();
double getTotal() const; double getTotal() const;
OrderStatus getStatus() const; OrderStatus getStatus() const;
void setStatus(const OrderStatus&); void setStatus(const OrderStatus&);
const std::string& getCustomerUsername(); int getCustomerId() const;
int getRestaurantId() const;
std::string serialize() const;
static std::shared_ptr<Order> deserialize(const std::string&);
}; };
@@ -3,10 +3,23 @@ Author: Joel Mathew Thomas
Date: 18-02-2026 Date: 18-02-2026
*/ */
#include <sstream>
#include "Restaurant.h" #include "Restaurant.h"
int Restaurant::m_uid = 0; int Restaurant::m_uid = 0;
Restaurant::Restaurant(int id, const std::string& name, bool isOpen, int ownerId) :
m_id(id),
m_name(name),
m_isOpen(isOpen),
m_ownerId(ownerId)
{
if (id > m_uid)
{
m_uid = id;
}
}
int Restaurant::getId() const int Restaurant::getId() const
{ {
return m_id; return m_id;
@@ -52,3 +65,44 @@ void Restaurant::setStatus(bool status)
{ {
m_isOpen = status; m_isOpen = status;
} }
int Restaurant::getOwnerId() const
{
return m_ownerId;
}
std::string Restaurant::serialize() const
{
std::ostringstream serializedRestaurant;
serializedRestaurant << m_id << '|'
<< m_name << '|'
<< (m_isOpen ? '1' : '0') << '|'
<< m_ownerId;
return serializedRestaurant.str();
}
std::shared_ptr<Restaurant> Restaurant::deserialize(const std::string& record)
{
int id, ownerId;
std::string name, token;
bool isOpen;
std::istringstream serializedRestaurant(record);
getline(serializedRestaurant, token, '|');
try {
id = std::stoi(token);
}
catch (...) {
throw std::runtime_error("Invalid Restaurant ID in snapshot");
}
getline(serializedRestaurant, name, '|');
getline(serializedRestaurant, token, '|');
isOpen = (token == "1");
getline(serializedRestaurant, token, '|');
try {
ownerId = std::stoi(token);
}
catch (...) {
throw std::runtime_error("Invalid Owner ID for Restaurant in snapshot");
}
return std::make_shared<Restaurant>(id, name, isOpen, ownerId);
}
@@ -22,17 +22,21 @@ private:
menuItems m_menuItems; menuItems m_menuItems;
orders m_orders; orders m_orders;
bool m_isOpen; bool m_isOpen;
int m_ownerId;
public: public:
Restaurant() : Restaurant() :
m_id(++m_uid), m_id(++m_uid),
m_name(""), m_name(""),
m_isOpen(true) m_isOpen(true),
m_ownerId(0)
{} {}
Restaurant(const std::string& name) : Restaurant(const std::string& name, int ownerId) :
m_id(++m_uid), m_id(++m_uid),
m_name(name), m_name(name),
m_isOpen(true) m_isOpen(true),
m_ownerId(ownerId)
{} {}
Restaurant(int, const std::string&, bool, int);
int getId() const; int getId() const;
void addMenuItem(const MenuItem&); void addMenuItem(const MenuItem&);
menuItems& getMenuItems(); menuItems& getMenuItems();
@@ -41,4 +45,7 @@ public:
void addOrder(std::shared_ptr<Order>); void addOrder(std::shared_ptr<Order>);
bool getStatus() const; bool getStatus() const;
void setStatus(bool); void setStatus(bool);
int getOwnerId() const;
std::string serialize() const;
static std::shared_ptr<Restaurant> deserialize(const std::string&);
}; };
@@ -25,6 +25,15 @@ public:
const std::string& email, const std::string& email,
const std::string& address) : const std::string& address) :
User(username, name, phone, password, email, address) User(username, name, phone, password, email, address)
{}
RestaurantOwner(int id,
const std::string& username,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& address) :
User(id, username, name, phone, password, email, address)
{} {}
void addRestaurant(std::shared_ptr<Restaurant>); void addRestaurant(std::shared_ptr<Restaurant>);
restaurants& getRestaurants(); restaurants& getRestaurants();
@@ -161,6 +161,14 @@
<ClInclude Include="RestaurantOwnerMenu.h" /> <ClInclude Include="RestaurantOwnerMenu.h" />
<ClInclude Include="User.h" /> <ClInclude Include="User.h" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Text Include="assignments.txt" />
<Text Include="items.txt" />
<Text Include="menuItems.txt" />
<Text Include="orders.txt" />
<Text Include="restaurants.txt" />
<Text Include="users.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
@@ -135,4 +135,22 @@
<Filter>Utility</Filter> <Filter>Utility</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Text Include="users.txt">
<Filter>Files</Filter>
</Text>
<Text Include="restaurants.txt">
<Filter>Files</Filter>
</Text>
<Text Include="menuItems.txt">
<Filter>Files</Filter>
</Text>
<Text Include="orders.txt">
<Filter>Files</Filter>
</Text>
<Text Include="items.txt">
<Filter>Files</Filter>
</Text>
<Text Include="assignments.txt" />
</ItemGroup>
</Project> </Project>
@@ -3,7 +3,40 @@ Author: Joel Mathew Thomas
Date: 18-02-2026 Date: 18-02-2026
*/ */
#include <sstream>
#include <stdexcept>
#include "User.h" #include "User.h"
#include "RestaurantOwner.h"
#include "Customer.h"
#include "DeliveryPartner.h"
int User::m_uid = 0;
User::User(int id,
const std::string& username,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& address) :
m_id(id),
m_username(username),
m_name(name),
m_phone(phone),
m_password(password),
m_email(email),
m_address(address)
{
if (id > m_uid)
{
m_uid = id;
}
}
int User::getId() const
{
return m_id;
}
std::string User::getUsername() const std::string User::getUsername() const
{ {
@@ -34,3 +67,47 @@ bool User::login(const std::string& password) const
{ {
return password == m_password; return password == m_password;
} }
std::string User::serialize() const
{
std::ostringstream serializedUser;
serializedUser << m_id << '|'
<< m_username << '|'
<< m_name << '|'
<< m_phone << '|'
<< m_password << '|'
<< m_email << '|'
<< m_address << '|'
<< getType();
return serializedUser.str();
}
std::shared_ptr<User> User::deserialize(const std::string& record)
{
int id;
std::string username, name, phone, password, email, address, type, token;
std::istringstream serializedUser(record);
getline(serializedUser, token, '|');
try {
id = std::stoi(token);
}
catch (...) {
throw std::runtime_error("Invalid User ID in snapshot");
}
getline(serializedUser, username, '|');
getline(serializedUser, name, '|');
getline(serializedUser, phone, '|');
getline(serializedUser, password, '|');
getline(serializedUser, email, '|');
getline(serializedUser, address, '|');
getline(serializedUser, type, '|');
if (type == "RestaurantOwner")
return std::make_shared<RestaurantOwner>(id, username, name, phone, password, email, address);
else if (type == "Customer")
return std::make_shared<Customer>(id, username, name, phone, password, email, address);
else if (type == "DeliveryPartner")
return std::make_shared<DeliveryPartner>(id, username, name, phone, password, email, address);
else {
throw std::runtime_error("Cannot deserialize User. Snaphshot is corrupted!");
}
}
@@ -5,10 +5,13 @@ Date: 17-02-2026
#pragma once #pragma once
#include <string> #include <string>
#include <memory>
class User class User
{ {
private: private:
static int m_uid;
int m_id;
std::string m_username; std::string m_username;
std::string m_name; std::string m_name;
std::string m_phone; std::string m_phone;
@@ -16,7 +19,8 @@ private:
std::string m_email; std::string m_email;
std::string m_address; std::string m_address;
public: public:
User(): User() :
m_id(0),
m_username(""), m_username(""),
m_name(""), m_name(""),
m_phone(""), m_phone(""),
@@ -30,6 +34,7 @@ public:
const std::string& password, const std::string& password,
const std::string& email, const std::string& email,
const std::string& address): const std::string& address):
m_id(++m_uid),
m_username(username), m_username(username),
m_name(name), m_name(name),
m_phone(phone), m_phone(phone),
@@ -37,7 +42,15 @@ public:
m_email(email), m_email(email),
m_address(address) m_address(address)
{} {}
User(int,
const std::string&,
const std::string&,
const std::string&,
const std::string&,
const std::string&,
const std::string&);
virtual ~User() = default; virtual ~User() = default;
int getId() const;
std::string getUsername() const; std::string getUsername() const;
std::string getName() const; std::string getName() const;
std::string getPhone() const; std::string getPhone() const;
@@ -45,5 +58,7 @@ public:
std::string getAddress() const; std::string getAddress() const;
virtual std::string getType() const = 0; virtual std::string getType() const = 0;
bool login(const std::string&) const; bool login(const std::string&) const;
std::string serialize() const;
static std::shared_ptr<User> deserialize(const std::string&);
}; };
@@ -0,0 +1,150 @@
1|Grilled Chicken|Classic grilled chicken|12.5|1
2|Veg Burger|Vegetable patty burger|8|1
3|Cheese Burger|Beef burger with cheese|10|1
4|French Fries|Crispy fries|4.5|1
5|Grilled Sandwich|Toasted sandwich|6|1
6|Chicken Wrap|Grilled chicken wrap|9|1
7|Veg Wrap|Vegetable wrap|7.5|1
8|Cola|Chilled soft drink|2|1
9|Iced Tea|Cold brewed tea|2.5|1
10|Brownie|Chocolate brownie|5|1
11|Pasta Alfredo|Creamy pasta|11|2
12|Pasta Marinara|Tomato pasta|10|2
13|Garlic Bread|Toasted garlic bread|4|2
14|Caesar Salad|Fresh salad|7.5|2
15|Grilled Veggies|Seasonal vegetables|6.5|2
16|Chicken Pasta|Pasta with chicken|12.5|2
17|Soup of the Day|Daily soup|5|2
18|Coffee|Hot brewed coffee|3|2
19|Tea|Hot tea|2.5|2
20|Cheesecake|Classic cheesecake|6|2
21|Veg Bowl|Healthy veg bowl|9|3
22|Chicken Bowl|Protein chicken bowl|11.5|3
23|Quinoa Salad|Quinoa mixed salad|10|3
24|Fruit Salad|Fresh fruit mix|6|3
25|Avocado Toast|Toasted avocado bread|7.5|3
26|Smoothie|Fruit smoothie|5.5|3
27|Grilled Tofu|Tofu with herbs|9.5|3
28|Veg Soup|Warm vegetable soup|5|3
29|Green Juice|Fresh juice|4.5|3
30|Yogurt Cup|Chilled yogurt|3.5|3
31|Chicken Wings|Spicy wings|10.5|4
32|Veg Nuggets|Crispy nuggets|7|4
33|Loaded Fries|Fries with toppings|8.5|4
34|Chicken Burger|Burger with chicken|9.5|4
35|Veg Burger|Classic veg burger|8|4
36|Onion Rings|Crispy onion rings|5|4
37|Hot Dog|Grilled hot dog|6.5|4
38|Milkshake|Vanilla milkshake|4.5|4
39|Soda|Carbonated drink|2|4
40|Ice Cream|Vanilla scoop|3.5|4
41|Breakfast Combo|Eggs and toast|8|5
42|Pancakes|Fluffy pancakes|6.5|5
43|Omelette|Cheese omelette|5.5|5
44|Toast Butter|Buttered toast|3|5
45|Fruit Plate|Seasonal fruits|4.5|5
46|Lunch Plate|Daily lunch meal|10|5
47|Veg Curry|Mixed veg curry|8.5|5
48|Rice Bowl|Steamed rice|4|5
49|Tea|Hot tea|2|5
50|Coffee|Fresh coffee|3|5
51|Chicken Rice|Rice with chicken|11|6
52|Veg Rice|Rice with vegetables|9|6
53|Noodles|Stir fried noodles|8.5|6
54|Veg Manchurian|Veg balls in sauce|9.5|6
55|Chicken Manchurian|Chicken in sauce|11.5|6
56|Spring Rolls|Crispy rolls|6|6
57|Fried Rice|Classic fried rice|8|6
58|Hot Soup|Soup bowl|4.5|6
59|Cold Drink|Chilled beverage|2.5|6
60|Ice Cream|Chocolate scoop|3.5|6
61|Chicken Sandwich|Grilled sandwich|8.5|7
62|Veg Sandwich|Vegetable sandwich|7|7
63|Club Sandwich|Triple layer sandwich|9.5|7
64|French Fries|Crispy fries|4|7
65|Cheese Toast|Toasted cheese|5|7
66|Soup|Daily soup|4.5|7
67|Salad|Fresh salad|6|7
68|Cold Coffee|Iced coffee|3.5|7
69|Tea|Hot tea|2|7
70|Brownie|Chocolate brownie|5.5|7
71|Steak|Grilled steak|15|8
72|Chicken Steak|Chicken fillet|13|8
73|Veg Steak|Grilled veg steak|11|8
74|Mashed Potato|Creamy potato|5.5|8
75|Grilled Veggies|Mixed vegetables|6.5|8
76|Soup|Chef special soup|5|8
77|Garlic Bread|Toasted bread|4.5|8
78|Soft Drink|Cold beverage|2.5|8
79|Dessert|Daily dessert|6|8
80|Ice Cream|Vanilla ice cream|3.5|8
81|Chicken Pizza|Thin crust pizza|12|9
82|Veg Pizza|Vegetable pizza|10|9
83|Cheese Pizza|Cheesy pizza|11|9
84|Garlic Bread|Garlic breadsticks|4.5|9
85|Pasta|Italian pasta|9.5|9
86|Salad|Side salad|5|9
87|Chicken Wings|Spicy wings|8.5|9
88|Cola|Cold cola|2|9
89|Brownie|Chocolate brownie|5.5|9
90|Ice Cream|Vanilla scoop|3.5|9
91|Soup Bowl|Warm soup|5|10
92|Veg Curry|Vegetable curry|8.5|10
93|Chicken Curry|Spicy chicken curry|10.5|10
94|Rice|Steamed rice|4|10
95|Flatbread|Soft flatbread|3|10
96|Salad|Fresh salad|6|10
97|Dessert|Sweet dessert|5.5|10
98|Tea|Hot tea|2|10
99|Coffee|Fresh coffee|3|10
100|Ice Cream|Chocolate scoop|3.5|10
101|Veg Bowl|Healthy veg bowl|9|11
102|Tofu Stir Fry|Tofu with veggies|10.5|11
103|Green Salad|Fresh greens|7|11
104|Veg Soup|Warm soup|5|11
105|Smoothie|Fruit smoothie|5.5|11
106|Grilled Veg|Grilled vegetables|8.5|11
107|Rice Bowl|Steamed rice|4|11
108|Juice|Fresh juice|4.5|11
109|Tea|Herbal tea|2.5|11
110|Fruit Cup|Mixed fruits|3.5|11
111|BBQ Chicken|Grilled BBQ chicken|13|12
112|BBQ Veg|Grilled veg platter|11|12
113|Roasted Potatoes|Herb potatoes|6|12
114|Grilled Corn|Butter corn|5.5|12
115|Chicken Skewers|Skewered chicken|12|12
116|Veg Skewers|Vegetable skewers|9.5|12
117|Soup|Hot soup|4.5|12
118|Soft Drink|Cold drink|2.5|12
119|Dessert|Sweet dish|5.5|12
120|Ice Cream|Vanilla ice cream|3.5|12
121|Chicken Burger|Fast chicken burger|9.5|13
122|Veg Burger|Quick veg burger|8|13
123|French Fries|Golden fries|4|13
124|Chicken Nuggets|Crispy nuggets|7|13
125|Veg Nuggets|Veg nuggets|6.5|13
126|Wrap|Quick wrap|7.5|13
127|Soft Drink|Cold beverage|2.5|13
128|Milkshake|Chocolate shake|4.5|13
129|Ice Cream|Vanilla scoop|3.5|13
130|Cookie|Choco cookie|2.5|13
131|Veg Platter|Mixed veg platter|10|14
132|Chicken Platter|Chicken platter|12.5|14
133|Soup|Warm soup|5|14
134|Salad|Fresh salad|6|14
135|Rice Bowl|Rice bowl|4.5|14
136|Flatbread|Soft bread|3|14
137|Dessert|Sweet dessert|5.5|14
138|Tea|Hot tea|2|14
139|Coffee|Fresh coffee|3|14
140|Ice Cream|Vanilla ice cream|3.5|14
141|Chicken Wrap|Spicy chicken wrap|9.5|15
142|Veg Wrap|Veggie wrap|8|15
143|Rice Bowl|Rice bowl|4.5|15
144|Noodles|Stir noodles|8.5|15
145|Soup|Hot soup|5|15
146|Grilled Chicken|Herb grilled chicken|12|15
147|Salad|Fresh salad|6|15
148|Soft Drink|Cold drink|2.5|15
149|Dessert|Sweet dessert|5.5|15
150|Ice Cream|Chocolate ice cream|3.5|15
@@ -0,0 +1,15 @@
1|Urban Grill|1|1
2|Corner Bistro|1|1
3|Fresh Plate|1|1
4|The Food Spot|0|1
5|Daily Dine|1|1
6|Metro Kitchen|1|2
7|Central Eats|1|2
8|Prime Bites|1|2
9|Kitchen Square|0|2
10|Table & Spoon|1|2
11|Green Fork|1|3
12|Open Flame|1|3
13|Quick Serve|1|3
14|Urban Table|0|3
15|Flavor Hub|1|3
@@ -0,0 +1,9 @@
1|alex|Alex Miller|100000001|alex|alex@mail.com|CityOne|RestaurantOwner
2|jordan|Jordan Smith|100000002|jordan|jordan@mail.com|CityTwo|RestaurantOwner
3|taylor|Taylor Brown|100000003|taylor|taylor@mail.com|CityThree|RestaurantOwner
4|emma|Emma Wilson|100000004|emma|emma@mail.com|CityOne|Customer
5|liam|Liam Johnson|100000005|liam|liam@mail.com|CityTwo|Customer
6|olivia|Olivia Davis|100000006|olivia|olivia@mail.com|CityThree|Customer
7|noah|Noah Anderson|100000007|noah|noah@mail.com|CityOne|DeliveryPartner
8|ava|Ava Martinez|100000008|ava|ava@mail.com|CityTwo|DeliveryPartner
9|ethan|Ethan Thomas|100000009|ethan|ethan@mail.com|CityThree|DeliveryPartner