Advanced Mode

various: Up to 15 points


Objective

For this task you’ll add an option to enable an “advanced user” mode, which allows the user to customize the display.

Requirements

1. Enabling advanced mode

A key motivation for having an “advanced mode” is to hide complexity from your user unless they specifically ask for it. For this reason, we will only make a very small change to the default behavior of main.py that allows the user to enable advanced mode if they want to. To fulfill this requirement, your program should do all of the following:

  • Before asking the user to choose an algorithm or a visualization style, ask the user whether they want to enable advanced mode. For example, running python3 main.py might begin like this:
    Welcome to the sorting algorithm visualization tool!
    Enable advanced mode? (y/n)
    Please enter a selection:
    
  • After receiving the user’s input, the program should display a short message indicating whether the program will run in “standard” or “advanced” mode, according to their selection.
  • When running in standard mode, the program should continue with no further changes to its behavior.
  • If the user enables advanced mode, the program’s behavior should be modified as described in the next section.

2. Advanced mode behavior

When advanced mode is enabled, the user will have the ability to choose the arguments we use when creating our DataSet or VisualDataSet objects. In particular:

  • When running in advanced mode and using a text-based visualization, the program should prompt the user to specify the size, minimum and maximum values that it should use to create the DataSet object.
  • Similarly, when running in graphical mode, the user should be able to specify a width, height and bar_width.

It is up to you to decide how you want to request these values from the user. However, your input prompts should indicate which value you are asking for, and provide guidance to help the user enter an acceptable value. For example:

Enter the desired width of the display in pixels (10-1000): 

Finally, keep in mind that user input should not be able to crash your program. See the Testing section below for more details.

Testing

As mentioned when you first built your looping menu, an important requirement of your user interface is to process user input and handle unexpected user responses gracefully. As a reminder, this means that if the user enters an inappropriate value, you should display a message saying that the input was invalid and prompt them to try again. An invalid choice should not crash the program or cause it to exit prematurely.

This should still be the case for the user input you receive when running in advanced mode. However, since you will now be accepting user input for a wider range of values, you will need to think carefully about how to check that it makes sense for your program. Some things you may want to consider is whether the user’s response can be cast to the correct type, or whether it falls within a reasonable range.

Caution!

Again, watch out for unintended side-effects! Make sure to check all your code carefully to verify that it still works and its behavior has not changed.

Hints

  • Although advanced mode is intended to allow the user to customize the DataSet and VisualDataSet objects by specifying their own values for the parameters, you don’t have to accept every possible value.
  • For example, although it would be possible to create a DataSet object with a size of 1,000,000 items, this choice does not make much sense for a text-based visualization.
  • To reduce the likelihood of malfunctions caused by extreme values, you may wish to impose some reasonable restrictions on the ranges of values you’re willing to accept.
  • Make sure to inform the user of any restrictions when you prompt them for input values.