Could you help me write a C++ Program to do the following: This is to create a prototype for a Web browser. You’ll do this by transforming the file viewer we created in class into a browser for a web of files that are all located on a single computer. (This is in contrast to the real World Wide Web whose pages are located all over the world.) Details The files in this web of files are plain text files that may contain anchors that provide links to other files. More precisely, an anchor is a string of the form 1 where filename is the name of another file and text is a piece of text. For example, here’s a line of text that contains an anchor: More is available. To keep things simple, assume that every anchor is separated from adjacent text by white space and that the strings filename and text cannot contain white space. Your browser should work exactly like the file viewer, except for the following: 1. When an anchor is displayed, it should appear as [n] where n is a number that is unique to this anchor. In each file, anchors should be numbered in order, starting at 1. For example, if the line More is available. contains the 5th anchor of the file, then it should be displayed as follows: More [5] is available. 2. The browser should have a new command called go. This command asks the user for a number and then opens the file associated with the corresponding anchor: command: g link number: 5 2 In the above example, this should cause the file info.txt to be displayed. 3. The browser should have another new command called back that reopens the previous file. This requires the browser to keep a record of the files that have been visited. For example, if the user visits files A, B and then C, the back command would return to B. But note that using the back command again would go to A, not back to C. In other words, files should get added to the “history” only when they are visited by following a link (with the go command) or by using the open command, not by using the back command.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Could you help me write a C++ Program to do the following:

This is to create a prototype for a Web browser. You’ll do this by transforming the file viewer we created in class into a browser for a web of files that are all located on a single computer. (This is in contrast to the real World Wide Web whose pages are located all over the world.) Details The files in this web of files are plain text files that may contain anchors that provide links to other files. More precisely, an anchor is a string of the form 1 where filename is the name of another file and text is a piece of text. For example, here’s a line of text that contains an anchor: More is available. To keep things simple, assume that every anchor is separated from adjacent text by white space and that the strings filename and text cannot contain white space. Your browser should work exactly like the file viewer, except for the following:

1. When an anchor is displayed, it should appear as [n] where n is a number that is unique to this anchor. In each file, anchors should be numbered in order, starting at 1. For example, if the line More is available. contains the 5th anchor of the file, then it should be displayed as follows: More [5] is available.

2. The browser should have a new command called go. This command asks the user for a number and then opens the file associated with the corresponding anchor: command: g link number: 5 2 In the above example, this should cause the file info.txt to be displayed.

3. The browser should have another new command called back that reopens the previous file. This requires the browser to keep a record of the files that have been visited. For example, if the user visits files A, B and then C, the back command would return to B. But note that using the back command again would go to A, not back to C. In other words, files should get added to the “history” only when they are visited by following a link (with the go command) or by using the open command, not by using the back command.

4. The browser should format the contents of each file as follows. Each file is assumed to consist of a sequence of “words” separated by white space. Note that, in this context, a word may include punctuation. For example, the following line contains six words: Each component performs one well−defined task. When a file is displayed, all the words should be separated by a single blank space and arranged so that the lines are as long as possible but no longer than a maximum length specified by the user. If ever a word is longer than that length, it should be displayed on a line by itself. The program should ask the user for the maximum line length right after it asks for the window height. The maximum line length should be a number of characters, not words.

5. Besides anchors, files can contain two other elements that affect how the text is displayed. The line-break element, written, causes a new line to begin immediately, even if the maximum line length hasn’t been 3 reached. The new-paragraph element, written, causes a new paragraph to be started. When displayed, consecutive paragraphs should be separated by a single blank line. Blank lines in the input file should be ignored. To keep things simple, assume that the and elements are separated from surrounding text by white space.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education