Using Java - write a new class called Rack, to store an ArrayList of Tiles, to sort them using the Selection Sort algorithm, and finish the program.
class Main
{
publicstaticvoid main(String[] args)
{
Rack craigTiles = new Rack();
craigTiles.addTile(new Tile('H', 4));
craigTiles.addTile(new Tile('E', 1));
craigTiles.addTile(new Tile('L', 1));
craigTiles.addTile(new Tile('L', 1));
craigTiles.addTile(new Tile('O', 1));
craigTiles.addTile(new Tile('Z', 10));
craigTiles.addTile(new Tile('Y', 4));
craigTiles.sortHighToLow();
System.out.println("Craig's rack of tiles, in order from most valuable to least:");
System.out.println(craigTiles);
Rack bettoTiles = new Rack();
bettoTiles.addTile(new Tile('E', 1));
bettoTiles.addTile(new Tile('A', 1));
bettoTiles.addTile(new Tile('S', 1));
bettoTiles.addTile(new Tile('D', 2));
bettoTiles.addTile(new Tile('W', 4));
bettoTiles.addTile(new Tile('T', 1));
bettoTiles.addTile(new Tile('N', 1));
bettoTiles.sortHighToLow();
System.out.println("Betto's rack of tiles, in order from most valuable to least:");
System.out.println(bettoTiles);
}
}
/*
Sample Outputs:
Craig's rack of tiles, in order from most valuable to least:
Z H Y L O E L
Betto's rack of tiles, in order from most valuable to least:
W D S A E T N
*/