IComparable help

Signo.X

Well-known member
Joined
Aug 21, 2006
Messages
76
Location
Australia
Programming Experience
1-3
hi all,

i have 4 classes :

Maze :
-has an arraylist of rooms object

Room:
-name
-size
-has an array list of of doors object

Door:
-direction

TestMaze:
- a class to execute the Maze.

in class TestMaze, i wana be able to return a sorted list of doors,
so questions:
1.do i implemet the Icomparable in the room class or the test maze class?
2.whats the code to sort the arrayList of doors objects? any examples?

Thanks in advanced!
 
hi all,

i have 4 classes :

Maze :
-has an arraylist of rooms object

Room:
-name
-size
-has an array list of of doors object

Door:
-direction

TestMaze:
- a class to execute the Maze.

in class TestMaze, i wana be able to return a sorted list of doors,

Sorted list of Doors of what? the maze or the room?


Door must implement IComparable
Door must decide how it is sorted relative to another Door

After that, Room should probably have:

VB.NET:
  Public Function SortedDoorList() As ArrayList
    myDoors.Sort()
    return myDoors
  End Function

Test maze might do:

VB.NET:
  For Each r as Room in theMaze
    someFunction_PrintDoorList( r.SortedDoorList() )
  Next r
 
Back
Top