Arrays.sort()
. What should I do?Arrays.sort()
is in the package java.util.Arrays
, so you need to include
the following import statement at the beginning of your program.
If you use our custom version of IntelliJ, the IDE will automatically add (and remove) the import statement as needed.import java.util.Arrays;
Arrays.sort()
know to call the compareTo()
method that I defined?Bar
, Java calls the compareTo()
method
that you implemented in the class Bar
.
implements Comparable<Bar>
in class declaration?Arrays.sort()
with an array
of Bar
objects.
The argument to Arrays.sort()
must be an array of comparable objects; otherwise,
Java cannot guarantee the existence of the compareTo()
method at compile time.
implements Comparable<Bar>
but don’t implement the
compareTo()
method?implements Comparable<Bar>
, you are promising to implement a method named
compareTo()
with the specified signature.
In
data type and read the file one line at a time.
Call readLine()
to read the next line of data
and call hasNextLine()
to detect whether you have reached the end of the file.
Integer.parseInt()
.
To parse a line containing a record, use the split()
method from the
String
library.
StdDraw.enableDoubleBuffering()
at the beginning of your program.
Then, you should repeatedly read a group of records.
When you are done reading a group of records (corresponding to one time period),
create the bar chart; clear the screen; draw the bar chart; call
StdDraw.show()
to display the bar chart on the screen; and call
StdDraw.pause(100)
to leave the bar chart on the screen for, say, 1/10 of a second.
You can adjust the parameter 100 to speed up or slow down the animation.
BarChart
determine which color to color the bars?