QUESTION PROVIDED IN ATTACH IMAGE KINDLY SEE. PROVIDE OUTPUT AS IT IS SHOWN IN QUESTION.
AND BELOW TEMPLATES PROVIDED CHECK THIS BEFORE MAKING SOLUTION ( main.cpp , user.cpp )
----------------- TEMPLATES BELOW FOR SOLUTION -----------------------
user.cpp template
#include <iostream> #include<string.h> using namespace std; class User{ private: string name; string userName; string password; public: void setName(string n) { name=n; } void setUserName(string un) { userName=un; } void setPassword(string p) { password=p; } string getName() {
//Fill your code
} string getUserName() {
//Fill your code
} string getPassword() {
//Fill your code
} User * getUserDetails(){ User *user = new User[5]; user[0].setName("Abi"); user[0].setUserName("Abinaya"); user[0].setPassword("abi123"); user[1].setName("Arun"); user[1].setUserName("Arunsoorya"); user[1].setPassword("arun456"); user[2].setName("Sbi"); user[2].setUserName("Sbiharan"); user[2].setPassword("sbi789"); user[3].setName("Sidhu"); user[3].setUserName("Siddarth"); user[3].setPassword("sid123"); user[4].setName("Vivi"); user[4].setUserName("Viveka"); user[4].setPassword("vivi456"); return user; } void display(string s) {
//Fill your code
} };
main.cpp template
#include<iostream> #include<string.h> #include "User.cpp" using namespace std;
string validate(string uname,string pword){ User u1; string name = ""; User *u = u1.getUserDetails(); //Fill your code return name;
}
int main() {
//Fill your code
return 0; }
Transcribed Image Text: It's Chandler Bing's birthday and his good friend Joey wants to throw a party for all the near and dear
ones. As Chandler Bing is a big star, so Joey knows the fact that the fans of the former would definitely
try to gate crash the party.
So he decides to keep a security system at the door that will ask the guest for their name and then
username and password which Joey himself assigned for each guest. If the credentials match then a
custom welcome message will be displayed and the gate will open, otherwise, it will display the message
"Invalid username/password".
Write a C++ program to validate the password using the friend function and use a public display
function to print the final output.
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class
names, member variable names, and function names should be the same as specified in the problem
statement.
The class User has the following private member variables
Variable
Data type
string
string
string
name
userName
password
Declare the following function to validate the user which will be able to access the private data
members of the User class in the main method.
Member Function
Description
Declare validate() as friend function.
This function is used to validate the username and password given by the
user. If the username and password match it returns the user name or else it
string validate(string userName, string password)
returns "No".
Declare the following member function inside the User class.
Member Function
User* getUserDetails()
Description
This method returns the already hardcoded name,
userName, and password. The method is already given as a
part of template
This function displays "Hii.userName ! Welcome to the
event!!! " if the validation is successful or else it displays
"Invalid username/password"
void display (string s)
In the main method, obtain input from the user in the console and create a new User object and assign
the values to the object's members using setters. Create a function validate() to verify the user
credentials and display the output using a public display function.
Input and Output format:
Input consists of three strings
First line of input corresponds to name
Second line of input corresponds to username
Third line of input corresponds to the password
Refer sample input and output for formatting specifications
[All text in bold corresponds to input and the rest corresponds to output]
Sample Input and Output 1:
Enter name:
vivi
Enter the username:
viveka
Enter the password:
vivi456
Hii.vivi ! Welcome to the event!!!
Sample Input and Output 2:
Enter name:
Suresh
Enter the username:
Sureshkumar
Enter the password:
suresh345
Invalid username/password