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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started