tom brownlee

+ Follow
since Aug 14, 2001
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by tom brownlee

excellent guys..thanks for the feedback
19 years ago
i have a text game im creating that has a 3x3 dimensioned space. i.e. 9 rooms in a 3x3 pattern. each room contains a jewel. i have a commandWords class that contains methods etc to read info from user. i also have a command class that determines first word and second word entries from the user i.e take jewel. my problem was in the game class that initiates the game i have a method 'take'.

here you can see that the second word is in the form of a colour (initial beginnings - it will get better) i.e. take Orange.
so here jewelColour equals the second word from the user (Orange). i need to cast it to the object Jewel (jewelInRoom) so i can manipulate it i.e. using if statements or while etc.
at the moment im printing to the console to test if im getting the cast right but i get the compile error due to the casting.

here i have in the 'Room' class two methods setContainedJewel and getContainedJewel in which i can change the jewel in each room when i 'take' the jewel.
does this help?
[ March 25, 2003: Message edited by: Dirk Schreckmann ]
19 years ago
how do i convert (cast) a String to an Object,
input a String from user and cast it to an Object to be manipulated
19 years ago
how can i put an object as the value in a hashmap
hashMap.put("some key" , Object);
in my code i have a user enter in a jewel color where it should look up the hash table with the jewel colour as the key returning the jewel as an object in which i can then manipulate with other methods.
how do i do this?
19 years ago
how do i initialize a class reference?
what i mean is: for int its, int i = 0;
for String its, String s = "";
so to use a method from another class i would use, say (my problem code)

where the 'jewelInRoom' method is in the Jewel class.
everytime i compile it, it works but at runtime i get a problem where i haven't initialized 'currentJewel'. i presume if i initialize the currentJewel to a color(parimeter of Jewel) the code wont work. well at least it didnt when i did it. i tested it by printing out jewelInRoom and i got 'null' on the screen when i should of got the jewel color(more code needed to understand) i know theres more code to add to properly make this sound sane but am i doing it it because im initializing currentJewel to a color that i get 'null' on screen, or is there an initializing code to use to make this work? as with int i = 0; or String s = '';
19 years ago
awesome corey..thanks for the did work...
my problem now is how do i access a method in a class from inside another class.
ie access the method jewelDescription in the Jewel class from the Room class (where i print out the jewel description as i move from room to room)

here ??? represents what i need to add to display the jewel description in that particular room.
19 years ago
hi people...a question all the way from new zealand.
i have an assignment, of which i can choose, the only rule is that it must be a short text based adventure game. simple?. well my game is a jewel game. heres my problem.
it has nine rooms (3x3) of which you start in a room and move through the rooms by the 'go' command. each movement is by way of north,south, east,west. ie go north.
this movement will return the room, in my case the rooms are labelled as colours. this is ok for me to code. BUT, in each room is a coloured jewel, the same colours as the room colours, but a different coloured jewel in each room, the goal of my game(to win)is to put a specific jewel in a specific room by way of a 'pick up' and 'put down' method, using clues(im not sure yet),
the problem??
how do i assign the coloured jewel to the room.
(and i suppose i should ask also how can i move jewel, from room to room).
below is my game class...(1 class from 6)

as you can see here i have no clue to what i should do next. no idea as to what i should do to allocate a jewel to a room.
please any help would be marvellous!

(edited by Cindy to format code using [ code] and [ /code] tags without the spaces)
[ March 18, 2003: Message edited by: Cindy Glass ]
19 years ago
Hi dirk, , my apologise for the confusion
after i posted the question i conceived the answer i needed. my next question that you ask about is this.
how do i store (save) a users details (first name, last name etc.) so that when they enter or re-enter their "code" they will be able to see these entries (first name, last name etc).
also how do i implement saving details if the users code does not exist and they are able to enter details to be saved under this code
(and hence re-entering the code to see these newly added details) or when they wish to modify their details?
does that make more sense dirk?
thanks for the help, i truly appreciate it.
20 years ago
Well ive discovered a crude but working way to implement my validation but now i need to know how to store user information ( firstname, lastname etc) into a hashtable and retrieve this information based upon the employee code entered in the employee code textfield.
therefore when the first code and password are valid the employee code is entered which should return the information of the appropriate employee with that code, but if it doesnt the user can enter new information and then store this via a GUI "add" button
any help?

thanks guys
20 years ago
Sorry Guys...
im using BlueJ to run my java code and therefore im using a TestRunner class to run my code. I didnt include the main() method to run the code when i posted it to you.
here it is

20 years ago
hello there,
my problem is one of frustration and impatience.
I have a swing GUI interface (code written below)that asks for a code and a password. I need to check the validity of both to enable the program to proceed.
how do i acccomplish this?
The code and password has to be stored somewhere in the program. (hashtable or vector or file etc).
As you may see when running the code, i also have to store and be able to retrieve information when put in by a user, but i thought id start out slowly. I am a reasonably competent java user, so please throw anything at me
My apologise if this isnt a beginner question, it seemed a good place to start.

thanks all.
20 years ago
sorry marilyn
i think it must of been the way i wrote the code should be on one line...with that solved it still doesnt compile.
any reason why?
and when i use methods instead of classes it still doesnt work?
any idea why?
20 years ago
hi guys..i have this code to count a character within a given source file..why wont it run/(it doesnt seem to compile either)
class Main
public static void main( String args[] )
int count = 0;
int ch =;
while ( ch == '/')
ch =;
System.out.println( "Total number of characters: " + count );
catch ( IOException err )
System.out.println("Unexpected error on

any help?
also i have this code (below) for calculating the lines in a source code (any random source code) how can i combine both codes (above and below) to produce code that will calculate the amount of logical lines in a source code?
ive asked b4, given it ago, but im stuck at this point..can i get the answer???
thanks guys for your time and effort
20 years ago
can i have an example of code where i can see this in context.
ive tried but obviously im missing something
an example would be good
thx guys
20 years ago
thanks michael for your mention a concrete example but no requirements...well thats pretty much it really..take a java source code, say we parse it, then the java code does the (i would say) searches the source code and filters out those lines that arent logical and returns the amount of lines that are...
does that help....any possibility for an example code?
cheers michael once again
regards tom
20 years ago