Question: Java Programming Assignment 6 The Web Browser Web browsers are deceptively complex programs. The simple task of opening a web page carries a lot of

Java Programming Assignment 6 The Web Browser

Web browsers are deceptively complex programs. The simple task of opening a web page carries a lot of steps: networking calls, protocol exchanges, rendering graphics, download and storage, JavaScript functionality, etc. Its a lot to handle. The myriad number of tasks at hand provides a great example of different situations for collecting and managing information. Perfect for trying out the Java Collections Classes.

Program requirements:

Create a new class, called WebBrowser. Inside it, place your main program. When run, your program will ask the user for commands.

The following commands should be provided:

o GOTO

o DOWNLOAD

o BACK

o FORWARD

o SHOW_DOWNLOADS

o CLEAR_DOWNLOADS

o SHOW_HISTORY

o CLEAR_HISTORY

o END

For the command above, should be any user-input String in the format of a typical web address.

Inside your WebBrowser main program, create the following:

o A Stack of Strings called backwards

o A Stack of Strings called forwards

o A Queue of Strings called downloads

o A List of Strings called history

o A String called currentURL

The command GOTO should place the users entered into the currentURL. It should also add it to the history list. If currentURL was not empty, the previous URL should be added to the backwards Stack. Print out the currentURL

When the user types BACK, remove the top of the Stack backwards and place it in currentURL. Put the previous URL into the forwards Stack. If the backwards Stack is empty, alert the user that nothing happened. Print out the currentURL

When the user types FORWARD, remove the top of the Stack forwards and place it in currentURL. Put the previous URL into the backwards Stack. If the forwards Stack is empty, alert the user that nothing happened. Print out the currentURL

If a user types GOTO at any point, clear the forwards Stack. (Logically, once a user goes to a new site, the trail forward is lost.)

If a user types DOWNLOAD, add the currentURL to downloads

If a user types SHOW_DOWNLOADS, print the contents of downloads

If a user types CLEAR_DOWNLOADS, empty the contents of downloads

If a user types SHOW_HISTORY, print the contents of history

If a user types CLEAR_HISTORY, empty the contents of history

If a user types END, exit the program

Include appropriate comments throughout your code.

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!