Question: You will be completing a Greenfoot Java project to code a simulation of selection sort. Your scenario ( whose world should be 8 0 0

You will be completing a Greenfoot Java project to code a simulation of selection sort. Your
scenario (whose world should be 800 pixels wide and 600 pixels high) should process the
following key presses:
l(i.e. the L key). This should present a FileDialog box to the user, from which a file
should be selected. This file will contain integers ranging in value from 1 to 500. The first
(integer) value in the input value in the file represents the number of (additional) integers
that will follow. For example, a file whose contents are:
104521879110433312872119
would mean that there are 10 data values to consider, and those 10 data values are 45,21,87,
91,104,333,12,87,21, and 19. Note that values can occur more than once (for example, 21
in the above) and are not likely to already be in sorted order. Once the file is read, a vertical
bar should have been added to the world for each of the data values in the file. The height
of the vertical bar should be the value of the corresponding numeric value from the data file,
and the width should be the width of the world (800) divided by the number of data values
in the input file (10 in this example). The bars should be kept flush to the bottom and
arranged from left to right with no two bars overlapping, in the same order as they are listed
in the input file. You are guaranteed that there will be no more than 266 data values in any
input file (which means a total of 267 numbers, since the first one tells you how many values
are found in the rest of the input file).
n(i.e. the N key). This should perform the next step in the selection sort algorithm
on the data set. That is, it should find the smallest value (shortest bar) among those that
have not yet been explicitly sorted and swap that bar into its appropriate location (making
sure to show such on the screen). The swapped bar(s) should be highlighted and no other
key presses should be processed until 25 more calls to act are made. When another swap is
performed in the future, the bar(s) involved in the current swap should be un-highlighted.
s(i.e. the S key). This should cause the program to complete sorting the remaining
unsorted bars, making sure to highlight each swap as it is performed during this process.
Dont forget that Greenfoot will only display the last state of your objects during any one
call to act. In other words, this option needs to cause future calls to act() to behave differently
(instead of just having this option complete the remainder of the sorting process within the
current call to act). As you are sorting, you should wait 250
n calls to act between showing
swaps (where n is the number of data values in the input file).
You are being given a bar class for this project - do not waste time re-inventing the
Wheel, and make sure to utilize what you are being provided

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 Programming Questions!