/* Rack.java by Craig Persiko Starter file for Exercise for Chapter 13 in CS 111B This class stores an ArrayList of Tile objects, sorts them, and returns them via .toString() DO NOT CHANGE THE FOLLOWING CODE. YOUR JOB IS TO ADD THE FOLLOWING METHODS: .toString() .sortHighToLow() You may also add any helper methods you want, such as swapValues. Make sure to write the Selection Sort algorithm like in the class example, but using the Tile object's .compareTo method. You can copy my code from my example, and then change it to fit your program. Note that we want to sort Tiles from highest value to lowest (the opposite order from our example.) */ import java.util.ArrayList; class Rack { private ArrayList tiles; public Rack() { tiles = new ArrayList(); } public void addTile(Tile t) { tiles.add(t); } /* DO NOT CHANGE THE ABOVE CODE. YOUR JOB IS TO ADD THE FOLLOWING METHODS: .toString() .sortHighToLow() You may also add any helper methods you want, such as swapValues. Make sure to write the Selection Sort algorithm like in the class example, but using the Tile object's .compareTo method. You can copy my code from my example, and then change it to fit your program. Note that we want to sort Tiles from highest value to lowest (the opposite order from our example.) */
/*
Rack.java by Craig Persiko
Starter file for Exercise for Chapter 13 in CS 111B
This class stores an ArrayList of Tile objects,
sorts them, and returns them via .toString()
DO NOT CHANGE THE FOLLOWING CODE.
YOUR JOB IS TO ADD THE FOLLOWING METHODS:
.toString()
.sortHighToLow()
You may also add any helper methods you want,
such as swapValues.
Make sure to write the Selection Sort
in the class example, but using the Tile object's
.compareTo method. You can copy my code from my
example, and then change it to fit your program. Note
that we want to sort Tiles from highest value to
lowest (the opposite order from our example.)
*/
import java.util.ArrayList;
class Rack
{
private ArrayList<Tile> tiles;
public Rack()
{
tiles = new ArrayList<Tile>();
}
public void addTile(Tile t)
{
tiles.add(t);
}
/*
DO NOT CHANGE THE ABOVE CODE.
YOUR JOB IS TO ADD THE FOLLOWING METHODS:
.toString()
.sortHighToLow()
You may also add any helper methods you want,
such as swapValues.
Make sure to write the Selection Sort algorithm like
in the class example, but using the Tile object's
.compareTo method. You can copy my code from my
example, and then change it to fit your program. Note
that we want to sort Tiles from highest value to
lowest (the opposite order from our example.)
*/
Step by step
Solved in 4 steps with 4 images