Answered step by step
Verified Expert Solution
Question
1 Approved Answer
From our previous case study in the picture can u add 3 other classes which are 'placing order', 'pick product' and 'payment' from the given
From our previous case study in the picture can u add other classes which are 'placing order', 'pick product' and 'payment' from the given image. Also same technique applies which is must include inheritance and polymorphism in it which is overloading and overriding.
In the 'order' class, please User are able to confirm their order and it will show the number and arrangement of orders shown.
In the 'payment' class, User are have options to pay via cash or credit card, if credit card, then it will send email for authentication.
And for 'product' class it will display the product menu, and also enable User to pick product.
Minimum attibutes for a class is and minimum method for a class is also
Here is the source code to modify:
#include
#include
#include
class User
protected:
std::string username;
std::string password;
public:
Userstd::string username, std::string password : usernameusername passwordpassword
virtual bool loginstd::string username, std::string password
Check if the provided credentials match
return thisusername username && thispassword password;
void logout
Logic for logout
virtual void displayInfo
std::cout "User: username std::endl;
;
class Admin : public User
private:
int adminLevel;
public:
Adminstd::string username, std::string password, int adminLevel : Userusername password adminLeveladminLevel
void addNewUserstd::string username, std::string password
Add a new user logic
void removeUserstd::string username
Remove a user logic
bool loginstd::string username, std::string password override
Admin login logic
return User::loginusername password;
void displayInfo override
User::displayInfo;
std::cout "Admin Level: adminLevel std::endl;
;
class RegularUser : public User
private:
std::string email;
bool loggedIn;
public:
RegularUserstd::string username, std::string password, std::string email : Userusername password emailemail loggedInfalse
void sendEmailstd::string to std::string message
Send email logic
bool loginstd::string username, std::string password override
Regular user login logic
return User::loginusername password;
void displayInfo override
User::displayInfo;
std::cout "Email: email std::endl;
;
int main
Testing the implemented classes
Admin adminadmin "adminpass", ;
RegularUser useruser "userpass", "user@example.com";
Perform operations and tests here
if adminloginadmin "adminpass"
admin.displayInfo;
if userloginuser "userpass"
user.displayInfo;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started