wrote:
> I am new to Java. Can anyone give me some help, please?
>
> There are 2 classes: DisplayTile1 and TilingDemo1
> How can I implement Comparable in DisplayTile1 so that I can sort
> tiles by colour and then by number?
To implement an interface you add an implements clause to the class
declaration and write appropriate implementation methods. In this case
that would mean adding "implements Comparable" after "extends JPanel" in
the declaration of DisplayTile1, and then writing a compareTo(Object)
method, returning int, that implements the sort order you want. Read
the API docs for Comparable for the details of the method contract.
> What should be done in TilingDemo1 accordingly?
I couldn't say, exactly, because it's not clear which group of tiles you
want to sort. You can sort an array of mutually Comparable objects by
use of the sort(Object[]) method of class java.util.Arrays; perhaps
that's what you need.
[code snipped]
John Bollinger