Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are tasked with creating a web browser simulator. Your web browser simulator should use one list together with a variable containing the current index

image text in transcribedYou are tasked with creating a web browser simulator. Your web browser simulator should use one list together with a variable containing the current index to enable both the back button functionality and the forward button functionality. Your simulator will not actually display any webpages: it will just display the URL address of the current page that the user is on. (See sample run at the end of this Exercise.) When the user wishes to enter a new webpage address, s/he signals this by entering =. When the user wishes to go back, is entered. The user can quit by entering q when prompted.

1. Download and save a copy of lab4_browser.py from eClass. This file contains a main() function (done for you) which controls the flow of operation of a web browser simulation. In the following steps, you will complete the functions that this main() function calls.

2. Complete getAction(). This function prompts the user to enter either a = (to enter a new website address), (forward button), or q to quit the browser simulation. If the user enters something other than these 4 characters, an error message is displayed before re-prompting for a valid entry. This function has no inputs. This function returns the valid character entered by the user (str).

3. Complete goToNewSite(). This function is called when the user enters = during getAction(). This function prompts the user to enter a new website address, and returns that address as a string. It also updates the list (pages) and current index (current), as appropriate. (Hint: experiment with how the back and forward buttons work on a real web browser like Firefox or Chrome. After a new address is entered, can you still go forward?) Note that you do not need to explicitly return the list of websites because the list is a mutable object so pages is actually just an alias for the list called websites in your main function. The inputs for this function are the index of the current website (int), and a reference to the list holding the webpage addresses to go back and forward between.

4. Complete goBack(). This function is called when the user enters

5. Complete goForward(). This function is called when the user enters > during getAction(). An error message is displayed if there are no webpages stored in the forward history, and the index of the current site is returned (int). Otherwise, the index of the next website is retrieved (and returned as an int). The inputs for this function are the index of the current website (int), and a reference to the list holding the webpage addresses to go back and forward between.

Sample run: Currently viewing www.cs.ualberta.ca Enter = to enter a URL, to go forward, a to quit: 123 Invalid entry. Enter = to enter a URL, to go forward, q to quit: > Cannot go forward. Currently viewing www.cs.ualberta.ca Enter = to enter a URL, to go forward, q to quit: to go forward, q to quit: = URL: www.google.ca Currently viewing www.google.ca Enter = to enter a URL, to go forward, a to quit: to go forward, a to quit: > Currently viewing www.google.ca Enter = to enter a URL, to go forward, q to quit: = URL: docs.python.org Currently viewing docs.python.org Enter = to enter a URL, to go forward, a to quit: to go forward, q to quit: to go forward, q to quit: = URL: www.beartracks.ualberta.ca Currently viewing www.beartracks.ualberta.ca Enter = to enter a URL, to go forward, q to quit: > Cannot go forward. Currently viewing www.beartracks.ualberta.ca Enter = to enter a URL, to go forward, q to quit: to go forward, q to quit: > Currently viewing www.beartracks.ualberta.ca Enter = to enter a URL, to go forward, a to quit: q Browser closing...goodbye

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

Step: 3

blur-text-image

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

Intelligent Image Databases Towards Advanced Image Retrieval

Authors: Yihong Gong

1st Edition

1461375037, 978-1461375036

More Books

Students also viewed these Databases questions

Question

List behaviors to improve effective leadership in meetings

Answered: 1 week ago