Question: * NO HAND WRITING PLEASE * * in C++ please * File I/O In this laboratory, we are going to revisit the username-password problem by

* NO HAND WRITING PLEASE *

* in C++ please *

File I/O

In this laboratory, we are going to revisit the username-password problem by storing the usernames and passwords in a file. The file will consist of a single username and password per line with a space in between.

1- Create a class PasswordFile which has the following interface :

class PasswordFile { public: PasswordFile(string filename);// opens the file and reads the names/passwords in the vector entry void addpw(string u, string p); //this adds a new user/password to entry and writes entry to the file filename void delpw(string u); //this deletes the user u from the password file bool checkpw(string u, string p); // returns true is user exists and password matches private: string filename; // the file that contains password information vector user; // the list of usernames/passwords vector password; // the list of usernames/passwords }; 

The constructor accepts a filename, and reads the file one-line at a time and adds values to the vectors. The function addpw adds a user/password, and the function delpw deletes a user.

2- Now create a password.txt file with some entries such as :

jsmith turtle madams apple 

Also create a main program to test your classes :

int main() { PasswordFile passfile("password.txt"); passfile.addpw("dbotting","123qwe"); passfile.addpw("egomez","qwerty"); passfile.addpw("tongyu","liberty"); // write some lines to see if passwords match users }

* NO HAND WRITING PLEASE * * in C++ please * File

File LO In this laboratory, we are going to revisit the username-password problem by storing the usernames and passwords in a file. The file will consist of a single username and password per line with a space in between. 1. Create a class PasswordFile which has the following interface class PasswordFile public: PasswordFile (string filename)i// opens the file and reads the names/passwords in the vector entry void addpw(string u, string p)i //this adds a new user/password to entry and writes entry to the file filename void delpw(string u) //this deletes the user u from the password file bool checkpw(string u, string p)i / returns true is user exists and password matches private: string filename; the file that contains password information vector user the list of usernames/passwords vector

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!