Remove Address class and add Address attribute to class User
This commit is contained in:
@@ -1 +0,0 @@
|
||||
#include "Address.h"
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
Author: Joel Mathew Thomas
|
||||
Date: 18-12-2026
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
class Address
|
||||
{
|
||||
private:
|
||||
std::string m_street;
|
||||
std::string m_city;
|
||||
int m_pincode;
|
||||
public:
|
||||
Address() :
|
||||
m_street(""),
|
||||
m_city(""),
|
||||
m_pincode(0)
|
||||
{}
|
||||
Address(const std::string& street, const std::string& city, int pincode):
|
||||
m_street(street),
|
||||
m_city(city),
|
||||
m_pincode(pincode)
|
||||
{}
|
||||
std::string getAddress() const;
|
||||
};
|
||||
|
||||
@@ -21,8 +21,9 @@ public:
|
||||
const std::string& name,
|
||||
const std::string& phone,
|
||||
const std::string& password,
|
||||
const std::string& email) :
|
||||
User(username, name, phone, password, email)
|
||||
const std::string& email,
|
||||
const std::string& address) :
|
||||
User(username, name, phone, password, email, address)
|
||||
{}
|
||||
void addOrder(std::shared_ptr<Order>);
|
||||
orders& getOrders();
|
||||
|
||||
@@ -21,8 +21,9 @@ public:
|
||||
const std::string& name,
|
||||
const std::string& phone,
|
||||
const std::string& password,
|
||||
const std::string& email) :
|
||||
User(username, name, phone, password, email)
|
||||
const std::string& email,
|
||||
const std::string& address) :
|
||||
User(username, name, phone, password, email, address)
|
||||
{}
|
||||
void acceptDeliveryAssignment(std::shared_ptr<DeliveryAssignment>);
|
||||
deliveryAssignments& getAssignedDeliveries();
|
||||
|
||||
@@ -252,7 +252,7 @@ void FoodDeliveryController::registerUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string username, password, phone, name, email;
|
||||
std::string username, password, phone, name, email, address;
|
||||
util::clear();
|
||||
std::cout << "Enter Username: ";
|
||||
util::readString(username);
|
||||
@@ -269,6 +269,8 @@ void FoodDeliveryController::registerUser()
|
||||
util::readString(phone);
|
||||
std::cout << "Enter Email: ";
|
||||
util::readString(email);
|
||||
std::cout << "Enter Address: ";
|
||||
util::readString(address);
|
||||
while (true)
|
||||
{
|
||||
int choice;
|
||||
@@ -282,13 +284,13 @@ void FoodDeliveryController::registerUser()
|
||||
switch (choice)
|
||||
{
|
||||
case 1:
|
||||
m_users[username] = std::make_shared<RestaurantOwner>(username, name, phone, password, email);
|
||||
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);
|
||||
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);
|
||||
m_users[username] = std::make_shared<DeliveryPartner>(username, name, phone, password, email, address);
|
||||
break;
|
||||
case 4:
|
||||
return;
|
||||
@@ -742,6 +744,7 @@ void FoodDeliveryController::viewProfile() const
|
||||
<< 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) << "Email " << ": " << m_authenticatedUser->getEmail() << "\n"
|
||||
<< std::left << std::setw(10) << "Type " << ": " << m_authenticatedUser->getType() << "\n";
|
||||
<< std::left << std::setw(10) << "Type " << ": " << m_authenticatedUser->getType() << "\n"
|
||||
<< std::left << std::setw(10) << "Address " << ": " << m_authenticatedUser->getAddress() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,9 @@ public:
|
||||
const std::string& name,
|
||||
const std::string& phone,
|
||||
const std::string& password,
|
||||
const std::string& email) :
|
||||
User(username, name, phone, password, email)
|
||||
const std::string& email,
|
||||
const std::string& address) :
|
||||
User(username, name, phone, password, email, address)
|
||||
{}
|
||||
void addRestaurant(std::shared_ptr<Restaurant>);
|
||||
restaurants& getRestaurants();
|
||||
|
||||
@@ -123,7 +123,6 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Address.cpp" />
|
||||
<ClCompile Include="Customer.cpp" />
|
||||
<ClCompile Include="CustomerMenu.cpp" />
|
||||
<ClCompile Include="DeliveryAssignment.cpp" />
|
||||
@@ -144,7 +143,6 @@
|
||||
<ClCompile Include="User.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Address.h" />
|
||||
<ClInclude Include="Customer.h" />
|
||||
<ClInclude Include="CustomerMenu.h" />
|
||||
<ClInclude Include="DeliveryAssignment.h" />
|
||||
|
||||
-6
@@ -27,9 +27,6 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Address.cpp">
|
||||
<Filter>Models</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Customer.cpp">
|
||||
<Filter>Models</Filter>
|
||||
</ClCompile>
|
||||
@@ -86,9 +83,6 @@
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Address.h">
|
||||
<Filter>Models</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Customer.h">
|
||||
<Filter>Models</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -25,6 +25,11 @@ std::string User::getEmail() const
|
||||
return m_email;
|
||||
}
|
||||
|
||||
std::string User::getAddress() const
|
||||
{
|
||||
return m_address;
|
||||
}
|
||||
|
||||
bool User::login(const std::string& password) const
|
||||
{
|
||||
return password == m_password;
|
||||
|
||||
@@ -14,30 +14,35 @@ private:
|
||||
std::string m_phone;
|
||||
std::string m_password;
|
||||
std::string m_email;
|
||||
std::string m_address;
|
||||
public:
|
||||
User():
|
||||
m_username(""),
|
||||
m_name(""),
|
||||
m_phone(""),
|
||||
m_password(""),
|
||||
m_email("")
|
||||
m_email(""),
|
||||
m_address("")
|
||||
{}
|
||||
User(const std::string& username,
|
||||
const std::string& name,
|
||||
const std::string& phone,
|
||||
const std::string& password,
|
||||
const std::string& email):
|
||||
const std::string& email,
|
||||
const std::string& address):
|
||||
m_username(username),
|
||||
m_name(name),
|
||||
m_phone(phone),
|
||||
m_password(password),
|
||||
m_email(email)
|
||||
m_email(email),
|
||||
m_address(address)
|
||||
{}
|
||||
virtual ~User() = default;
|
||||
std::string getUsername() const;
|
||||
std::string getName() const;
|
||||
std::string getPhone() const;
|
||||
std::string getEmail() const;
|
||||
std::string getAddress() const;
|
||||
virtual std::string getType() const = 0;
|
||||
bool login(const std::string&) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user