![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | ||
|
Programmer
Join Date: Aug 2005
Location: 0x0010 * 0x0091 + 0x0004
Posts: 65
Rep Power: 4
![]() |
Quote:
Quote:
__________________
#if 0 /* in case someone actually tries to compile this */ <Jim_McNeat> Is there like a way to put a compiler in "Just trust me on that one" mode? |
||
|
|
|
|
|
#12 |
|
Newbie
Join Date: Nov 2005
Posts: 11
Rep Power: 0
![]() |
Thanks!! the Monster Class is fixxed...
Next is the Room Class... The addRoom(int) is reasonably simple. When addRoom(int) is called, it takes the value specified and stores it in the array intRooms[] at the location specified by intRoomCount. It then increases the pointer (intRoomCount) by one. Heres what i have so far.. public class Room
{
int intRooms[];
int intRoomCount = 0;
public void addRoom(int NewRoom)
{
intRooms[intRoomCount] = NewRoom;
++intRoomCount;
}Ive tried compiling and testing but it say there is an error... |
|
|
|
|
|
#13 |
|
Professional Programmer
|
What's the error ?
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#14 |
|
Newbie
Join Date: Nov 2005
Posts: 11
Rep Power: 0
![]() |
Null exception error
|
|
|
|
|
|
#15 |
|
Professional Programmer
|
Try : intRoomCount ++;
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#16 |
|
Newbie
Join Date: Nov 2005
Posts: 11
Rep Power: 0
![]() |
Got the same error, here is more detail:
java.lang.NullPointerException at Room.addRoom(Room.java:14) at RoomTest.main(RoomTest.java:33) |
|
|
|
|
|
#17 |
|
Professional Programmer
|
int intRooms[] = new int [20] ; // for example
I guess u could have a method that determines the number of rooms you want : int totalRooms = ??? ; and then have : int intRooms[] = new int [totalRooms];
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#18 |
|
Newbie
Join Date: Nov 2005
Posts: 11
Rep Power: 0
![]() |
SWEET! it works now...now i just have to figure out the rest of the code...
At this point its the interface: it just needs to consist of three Buttons and a Label. Each of the three Buttons will represent one room that the user can enter. The Label will tell the user what room they are in. To set things up, we need two things – a pointer, to know where we are, and an array of type Room. My question is how should i declare this array? Here is my Room Layout : - Room 0: 1, 4, 5 Room 1: 0, 2, 7 Room 2: 1, 3, 9 Room 3: 2, 4, 11 Room 4: 0, 3, 13 Room 5: 0, 6, 14 Room 6: 5, 7, 16 Room 7: 1, 6, 8 Room 8: 7, 9, 17 Room 9: 2, 8, 10 Room 10: 9, 11, 18 Room 11: 3, 10, 12 Room 12: 11, 13, 19 Room 13: 4, 12, 14 Room 14: 5, 13, 15 Room 15: 14, 16, 19 Room 16: 6, 15, 17 Room 17: 8, 16, 19 Room 18: 10, 17, 19 Room 19: 12, 15, 18 |
|
|
|
|
|
#19 |
|
Professional Programmer
|
Use a matrix Room[20][3].
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#20 |
|
Newbie
Join Date: Nov 2005
Posts: 11
Rep Power: 0
![]() |
I dont know how to use those, heheh thats a bit advanced for me...
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|