CS 2413 Programming Project 1 solution


Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment


5/5 - (3 votes)

1. [10 pts] Use basic input/output in C++ (cin and cout). 2. [10 pts] Use arrays in C/C++. 3. [10 pts] Create at least 2 C++ classes. 4. [50 pts] Design and implement the program according to the project description. 50 pts are distributed as follows: a. [10 pts] Read the input file using redirected input; print out each line read from the file. b. [10 pts] Add url to appropriate browserTab and corresponding webAddressInfo c. [10 pts] Implement the forward and backward methods. d. [10 pts] Implement the display method in browserTab class. e. [10 pts] Implement the display method in webAddressInfo class. 5. [20 pts] Document your project thoroughly as the examples in the textbook. This includes but not limited to header comments for all classes/methods, explanatory comments for each section of code, meaningful variable and method names, and consistent indentation. Project Description
A browser window consists of a many tabs. On each tab a user can enter a new web address (url) to go to, press the back button to go a url that was just visited, or press the forward button to go the url that was visited before the back button was pressed. A list of urls corresponding to a particular tab is kept in an array of characters. The goal of this project is to create appropriate classes and simulate the actions of a user on a web browser. When a user chooses forward or backward we need to just print the urls and do not have to write complex code to actually go to a website.
Given the above, we will first start with the description of the input. All input lines will be stored in a text file (file with txt extension) and we will use redirected input to read the contents of the file. Each line of input consists of three items (each separated by a single space): tab number (integer), action (single character), and the url (depending on the action). The possible actions that needs to be implemented for this project are N (for adding a url), B (pressing the backward button), and F (pressing the forward button), and P (for printing the urls).
For each action, print the action that is invoked, followed by the tab number, and followed by the result of the action. Both forward and backward actions should print the url that they go to. Add should provide the url that being added. The print P should print all the urls in the current tab.
Here is an example of the input file.
1 N http://www.msn.com/?ocid=iehp 1 N http://www.microsoftstore.com/store/msusa/en_US/home 1 B 1 F 1 P 3 N https://www.udacity.com/course/front-end-web-developer-nanodegree–nd001 1 N http://www.cnn.com/2016/01/24/us/weather-winter-snowstorm/index.html 1 P 1 B 1 B 1 P 2 N http://www.cnn.com/2016/01/24/us/weather-winter-snowstorm/index.html 2 N http://www.sas.com/en_us/software/university-edition.html 2 B 2 F 2 P
We will assume that the number of commands in the input file is unknown. Additionally, we will assume that the maximum number of tabs is 20 and the number of characters in each url is limited to 200.
In this project, you will write a C++ program that allows the users to perform all the actions described above. You will implement the C++ classes as described in this section and as well as the main() method which will read and execute the commands from standard I/O.
webAddressInfo Class
The webAddressInfo class is used to store the information on the urls in a particular tab, it is defined as follows:
class webAddressInfo { private: char url[201]; //allow a maximum of 200 characters // other private methods if necessary for this class public: webAddressInfo (); webAddressInfo (char* inputString); void setWebAddressInfo(char* inputString); char* getWebAddressInfo(); void display(); // and other public methods if necessary }; browserTab
The browserTab class is used to store the web address information for each tab, it is defined as follows: class browserTab { protected: int numAddress; //Current number of web addresses in this tab webAddressInfo webAddresses [20]; //Web addreses in this tab int currentAddress; //index of current location in webAddresses // other private methods if necessary for this class public: browserTab(); browserTab(char* inputString); //creates a new tab with the inputString webAddressInfo& forward(); webAddressInfo& backward(); void addAddress(char* inputString); void display(); // and other public methods if necessary };
main() method
The main() method reads different user actions from standard I/O as described earlier. You will implement the main() method as the code provided below.