User class definitions

This commit is contained in:
Joel Thomas
2026-02-18 13:14:08 +05:30
parent 7c17576e8c
commit b213cb1698
10 changed files with 98 additions and 21 deletions
@@ -1 +1,11 @@
#include "Customer.h"
void Customer::addOrder(std::shared_ptr<Order> orderPointer)
{
m_orders[orderPointer->getId()] = orderPointer;
}
orders& Customer::getOrders()
{
return m_orders;
}
@@ -4,17 +4,18 @@ Date: 17-02-2026
*/
#pragma once
#include <vector>
#include <map>
#include <memory>
#include "User.h"
#include "Order.h"
using orders = std::vector<Order*>;
using orders = std::map<int, std::shared_ptr<Order>>;
class Customer : public User
{
orders m_orders;
private:
void addOrder(Order*);
void addOrder(std::shared_ptr<Order>);
orders& getOrders();
};
@@ -1 +1,11 @@
/*
Author: Joel Mathew Thomas
Date: 18-02-2026
*/
#include "DeliveryPartner.h"
void DeliveryPartner::acceptDeliveryAssignment(std::shared_ptr<DeliveryAssignment> deliveryAssignmentPointer)
{
m_deliveryAssignments[deliveryAssignmentPointer->getId()] = deliveryAssignmentPointer;
}
@@ -4,18 +4,19 @@ Date: 17-02-2026
*/
#pragma once
#include <vector>
#include <map>
#include <memory>
#include "User.h"
#include "DeliveryAssignment.h"
using deliveryAssignments = std::vector<DeliveryAssignment*>;
using deliveryAssignments = std::map<int, std::shared_ptr<DeliveryAssignment>>;
class DeliveryPartner : public User
{
private:
deliveryAssignments m_deliveryAssignments;
public:
void acceptDeliveryAssignment(DeliveryAssignment*);
void acceptDeliveryAssignment(std::shared_ptr<DeliveryAssignment>);
deliveryAssignments& getAssignedDeliveries();
};
@@ -37,6 +37,7 @@ public:
m_status(OrderStatus::CREATED)
{}
~Order();
int getId() const;
void addItem();
void removeItem();
items& getItems();
@@ -32,6 +32,7 @@ public:
m_status(true)
{}
~Restaurant();
int getId() const;
menuItems& getMenuItems();
orders& getOrders();
bool getStatus() const;
@@ -1 +1,16 @@
/*
Author: Joel Mathew Thomas
Date: 18-02-2026
*/
#include "RestaurantOwner.h"
void RestaurantOwner::addRestaurant(std::shared_ptr<Restaurant> restaurantPointer)
{
m_restaurants[restaurantPointer->getId()] = restaurantPointer;
}
restaurants& RestaurantOwner::getRestaurants()
{
return m_restaurants;
}
@@ -4,18 +4,19 @@ Date: 17-02-2026
*/
#pragma once
#include <vector>
#include <map>
#include <memory>
#include "User.h"
#include "Restaurant.h"
#include "MenuItem.h"
using restaurants = std::vector<Restaurant*>;
using restaurants = std::map<int, std::shared_ptr<Restaurant>>;
class RestaurantOwner : public User
{
private:
restaurants m_restaurants;
public:
void addRestaurant(Restaurant*);
void addRestaurant(std::shared_ptr<Restaurant>);
restaurants& getRestaurants();
};
@@ -1 +1,36 @@
/*
Author: Joel Mathew Thomas
Date: 18-02-2026
*/
#include "User.h"
int User::getId() const
{
return m_id;
}
std::string User::getUsername() const
{
return m_username;
}
std::string User::getName() const
{
return m_name;
}
std::string User::getPhone() const
{
return m_phone;
}
std::string User::getEmail() const
{
return m_email;
}
bool User::login(const std::string& password) const
{
return password == m_password;
}
@@ -10,35 +10,37 @@ class User
{
private:
int m_id;
std::string m_username;
std::string m_name;
std::string m_phone;
std::string m_password;
std::string m_email;
bool m_isAuthenticated;
public:
User()
: m_id(0),
User():
m_username(""),
m_name(""),
m_phone(""),
m_password(""),
m_email(""),
m_isAuthenticated(false)
m_email("")
{}
User(int id,
const std::string& username,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email)
: m_id(id),
m_name(name),
const std::string& email):
m_username(""),
m_name(username),
m_phone(phone),
m_password(password),
m_email(email),
m_isAuthenticated(false)
m_email(email)
{}
virtual ~User() = default;
void login();
void logout();
std::string getUsername() const;
std::string getName() const;
std::string getPhone() const;
std::string getEmail() const;
bool login(const std::string&) const;
};