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 pixels wide and pixels high should process the
following key presses:
lie 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 to 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:
would mean that there are data values to consider, and those data values are
and Note that values can occur more than once for example,
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 divided by the number of data values
in the input file 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 data values in any
input file which means a total of numbers, since the first one tells you how many values
are found in the rest of the input file
nie 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 bars should be highlighted and no other
key presses should be processed until more calls to act are made. When another swap is
performed in the future, the bars involved in the current swap should be unhighlighted.
sie 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
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 reinventing 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
