various: Up to 15 points
For this task you’ll add an option to enable an “advanced user” mode, which allows the user to customize the display.
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:
python3 main.py
might begin like this:Welcome to the sorting algorithm visualization tool!
Enable advanced mode? (y/n)
Please enter a selection:
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:
size
, minimum
and maximum
values that it should use to create the DataSet
object.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.
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.
DataSet
and VisualDataSet
objects by specifying their own values for the parameters, you don’t have to accept every possible value.DataSet
object with a size
of 1,000,000 items, this choice does not make much sense for a text-based visualization.