Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ In this assignment you will create an extremely rudimentary bulletin board with a simple command-line interface (like in the old days!). This will

In C++

In this assignment you will create an extremely rudimentary bulletin board with a simple command-line interface (like in the old days!).

This will require three collaborating classes - BBoard, User, and Message. For the moment, the bulletin board will exist only inside the test harness (i.e. we won't store it to the file system yet), so you will construct a single BBoard object (giving it an appropriate title - e.g. "Jack's Amazing Bulletin Board"), and then invoke its methods.

First, you will "load it up" with a set of authorized Users (read in from a file);

then you will ask the user to log in with a username and password, which you will check against the list you just read in;

and then you will "run" the board: the program will enter a sentinel-controlled loop asking the user to choose from a menu of actions (corresponding, obviously, to BBoard's other public methods)

-list all current posts

-create a new post

-quit the system

Class Specifications:

User class interface

class User { private: string username; string password; public: // creates a user with empty name and password. User(); // creates a user with given username and password. User(const string &uname, const string &pass); //returns the username string getUsername() const; // returns true if the stored username/password matches with the // parameters. Otherwise returns false. // Note that, even though a User with empty name and password is // actually a valid User object (it is the default User), this // function must still return false if given a empty uname string. bool check(const string &uname, const string &pass) const; // sets a new password. // This function should only set the new password if the current (old) // password is passed in. Also, a default User cannot have its // password changed. // returns true if password changed, false if not. bool setPassword(const string &oldpass, const string &newpass); }; 

Message class interface

class Message { private: string author; string subject; string body; public: // default constructor Message(); // Constructor with parameters Message(const string &athr, const string &sbjct, const string &body); // Displays the message in the given format. See output specs. // Note: this function must output a single newline character // at the end (after the body). void display() const; }; 

BBoard class interface

class BBoard { private: string title; vector userList; User currentUser; vector messageList; public: // Constructs a board with a default title, // empty user & message lists, // and the "default" User BBoard(); // Same as the default constructor except // it sets the title of the board BBoard(const string &); // Imports all the authorized users from an input file, // storing them as User objects in the vector userList // The name of the input file is passed in as a parameter to this function. // See below for file format. bool loadUsers(const string &); // Asks for and validates a user/password. // Always asks for both user and password combo unless 'q' or 'Q' entered. // Checks userList to validate user and password. // If valid, sets currentUser to this User, outputs welcome message, // then returns true. // Otherwise outputs error message and then repeats request // for username/password. // Continues until valid user/password // or until 'q' or 'Q' is entered for username. // If 'q' or 'Q' is entered, does not ask for password, outputs "Bye!" // and then returns false. bool login(); // Contains main loop of Bulletin Board. // First verifies a User has been logged in. // Exits **function** immediately if no User logged in (Default User). // Continues to display menu options to user and performs requested action // until user chooses to quit. // See output samples for exact format of menu. void run(); // Suggested private helper functions (not required) // private: // void display() const; // void addMessage(); // bool userExists(const string &, const string &) const; }; 

main.cpp

The following is the main function that will be used for the compare output tests.

You will want to create your own main function when unit testing each of the class member functions.

#include  #include  using namespace std; #include "BBoard.h" int main() { string userfile; cout << "User file?" << endl; cin >> userfile; cout << endl; BBoard bb("CS12 Bulletin Board"); // load users from file if (!bb.loadUsers(userfile)) { cout << "Error loading users from file " << userfile << endl; return 1; } if (!bb.login()) { cout << "Login not successful" << endl; return 1; } bb.run(); return 0; } 

User File Specifications

 user1 pass1 user2 pass2 user3 pass3 ... end 

One user and password per line. Can be any number of users. Last line will have the word "end" followed by a newline.

The output samples below use a file named users1.txt that contains the following:

ali87 8422 ricq7 bjk1903 messi buneyinnessi mike ini99ou jenny Y00L11A09 end 

Output Specifications

Read the examples below and make sure your output matches exactly with the sample runs below (given the same inputs).

This is what your output will look like in cloud9:

Sample run 1

$ ./a.out User file? users1.txt Welcome to CS12 Bulletin Board Enter your username ('Q' or 'q' to quit): ali87 Enter your password: 8422 Welcome back ali87! Menu - Display Messages ('D' or 'd') - Add New Message ('N' or 'n') - Quit ('Q' or 'q') Choose an action: D Nothing to Display. Menu - Display Messages ('D' or 'd') - Add New Message ('N' or 'n') - Quit ('Q' or 'q') Choose an action: q Bye! 

Sample run 2

$./a.out User file? users1.txt Welcome to CS12 Bulletin Board Enter your username ('Q' or 'q' to quit): messi Enter your password: buneyinessi Invalid Username or Password! Enter your username ('Q' or 'q' to quit): messi Enter your password: buneyinnessi Welcome back messi! Menu - Display Messages ('D' or 'd') - Add New Message ('N' or 'n') - Quit ('Q' or 'q') Choose an action: N Enter Subject: Thanks a bunch!! Enter Body: Thanks for this amazing board! Message Recorded! Menu - Display Messages ('D' or 'd') - Add New Message ('N' or 'n') - Quit ('Q' or 'q') Choose an action: n Enter Subject: Chelsea vs Arsenal Enter Body: Have you seen the game from Wed yet? Better than El Clasico! Message Recorded! Menu - Display Messages ('D' or 'd') - Add New Message ('N' or 'n') - Quit ('Q' or 'q') Choose an action: n Enter Subject: Output Specifications Enter Body: So we just have to make our output look like the samples? Message Recorded! Menu - Display Messages ('D' or 'd') - Add New Message ('N' or 'n') - Quit ('Q' or 'q') Choose an action: D --------------------------------------------------------- Message #1: Thanks a bunch!! from messi: Thanks for this amazing board! --------------------------------------------------------- Message #2: Chelsea vs Arsenal from messi: Have you seen the game from Wed yet? Better than El Clasico! --------------------------------------------------------- Message #3: Output Specifications from messi: So we just have to make our output look like the samples? --------------------------------------------------------- Menu - Display Messages ('D' or 'd') - Add New Message ('N' or 'n') - Quit ('Q' or 'q') Choose an action: q Bye! 

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_2

Step: 3

blur-text-image_3

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

Students also viewed these Databases questions

Question

a. Prove that b. Prove that .3 /2

Answered: 1 week ago