Answered step by step
Verified Expert Solution
Link Copied!

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 3 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 3, and minimum method for a class is also 3
Here is the source code to modify:
#include
#include
#include
class User {
protected:
std::string username;
std::string password;
public:
User(std::string username, std::string password) : username(username), password(password){}
virtual bool login(std::string username, std::string password){
// Check if the provided credentials match
return (this->username == username && this->password == password);
}
void logout(){
// Logic for logout
}
virtual void displayInfo(){
std::cout "User: " username std::endl;
}
};
class Admin : public User {
private:
int adminLevel;
public:
Admin(std::string username, std::string password, int adminLevel) : User(username, password), adminLevel(adminLevel){}
void addNewUser(std::string username, std::string password){
// Add a new user logic
}
void removeUser(std::string username){
// Remove a user logic
}
bool login(std::string username, std::string password) override {
// Admin login logic
return User::login(username, password);
}
void displayInfo() override {
User::displayInfo();
std::cout "Admin Level: " adminLevel std::endl;
}
};
class RegularUser : public User {
private:
std::string email;
bool loggedIn;
public:
RegularUser(std::string username, std::string password, std::string email) : User(username, password), email(email), loggedIn(false){}
void sendEmail(std::string to, std::string message){
// Send email logic
}
bool login(std::string username, std::string password) override {
// Regular user login logic
return User::login(username, password);
}
void displayInfo() override {
User::displayInfo();
std::cout "Email: " email std::endl;
}
};
int main(){
// Testing the implemented classes
Admin admin("admin", "adminpass", 5);
RegularUser user("user", "userpass", "user@example.com");
// Perform operations and tests here
if (admin.login("admin", "adminpass")){
admin.displayInfo();
}
if (user.login("user", "userpass")){
user.displayInfo();
}
return 0;
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions