![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Professional Programmer
|
A matrix is an array of arrays it's not hard at all. http://java.sun.com/docs/books/tutor...ltiarrays.html - something to get you started , google for more , but you should get an ideea.
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#22 |
|
Newbie
Join Date: Nov 2005
Posts: 11
Rep Power: 0
![]() |
Hey xavier, yeah i tried that matrix method but i dint really work well so i just did some ugly codes...so its working now...
but there is still the need to create a new Method called something like “describeRoom()”. This Method should :; a) Change the Label to read “You are in room X”, where “X” is the room specified by the pointer (“intCurrentRoom”). b) Ask the room currently specified by the pointer (“intCurrentRoom”) what rooms lead off of it (getRooms(): int[]), and store the results (temporarily) in an array. c) Change the text (<button>.setLabel(<String>)) of each Button to be the value of one of those three exits. Here is wat i have in the 'work in progress code': public class Room
{
int intRooms[] = new int [19];
int intRoomCount = 0;
public void totalRooms(int newtotalRooms)
{
int intRooms[] = new int [newtotalRooms];
}
public void addRoom(int NewRoom)
{
//When new room is added Room count is increased
intRooms[intRoomCount] = NewRoom;
intRoomCount++;
//Array values
intRooms[0] = 1;
intRooms[0] = 4;
intRooms[0] = 5;
intRooms[1] = 0;
intRooms[1] = 2;
intRooms[1] = 7;
intRooms[2] = 1;
intRooms[2] = 3;
intRooms[2] = 9;
intRooms[3] = 2;
intRooms[3] = 4;
intRooms[3] = 11;
intRooms[4] = 0;
intRooms[4] = 3;
intRooms[4] = 13;
intRooms[5] = 0;
intRooms[5] = 6;
intRooms[5] = 14;
intRooms[6] = 5;
intRooms[6] = 7;
intRooms[6] = 16;
intRooms[7] = 1;
intRooms[7] = 6;
intRooms[7] = 8;
intRooms[8] = 7;
intRooms[8] = 9;
intRooms[8] = 17;
intRooms[9] = 2;
intRooms[9] = 8;
intRooms[9] = 10;
intRooms[10] = 9;
intRooms[10] = 11;
intRooms[10] = 18;
intRooms[11] = 3;
intRooms[11] = 10;
intRooms[11] = 12;
}
public int describeRoom()
{
return intCurrentRoom;
}
public int[] getRooms()
{
return intRooms;
}
public void intCurrentRoom()
{
int intCurrentRoom;
}
} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|