Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

* 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 }

image text in transcribed

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

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

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago