Jonathan King

Greenhorn
+ Follow
since Jan 28, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Jonathan King

I also have a question for you, James. In Java Demystified, do you present your programming topics and examples as if coding and running them through a console window, or is there some sort of GUI java program that you use throughout the book? (Bluebird, for example?)
20 years ago
All right guys and gals, I've been working on this for hours now, and I am stuck!! I get a user's choice from console, and perform some actions based on that choice. After, they can enter 'y' to try another menu choice, or any key to exit the program. I have gotten to where the program runs great, and when they choose y to try again, the menu will print, and they can do another choice, but if I want to choose 'y' again, it just ends. I would like to get it to loop so if they press 'y' 1000 times after running a choice (as long as it is not the exit choice) it will print the menu again and they can choose another choise. HOW!!! PLEASE EASE MY FRAZZLED MIND!!! ARGGGHHHH!!!

THANK YOU!!!
20 years ago
This is probably a stupid question, but what is WebSphere?? Is it just a java based Frontpage program?
Another question on this topic... (sorry for all the code taking up most of this post)
It seems to me that I would have to place these cards into the ArrayList inside of my while loop. However, I want to keep my card object as a separate class then my bridge hand, right? And so I would need to take my card objects and use my BridgeHand class to place them into an ArrayList from there. At least that is my thinking of proper Java coding etiquette...
Am I right in assuming this?
Jon
20 years ago
Oh, and my only test program is a BridgeHandTest.java
I am only writing code so far that I can get my objects into the ArrayList. After I can get that to work out, I plan on writing additional code to do things with the whole BridgeHand (like figure out points, etc.) But since I am a beginner with this whole List thing, I was trying to do it little bits at a time like this.
Here is the BridgeHandTest file:

[ February 01, 2004: Message edited by: Jonathan King ]
20 years ago
Okay, this is my data file. I only have one line in it so far, because I wanted to make sure my tokenizer even worked.

I get no exceptions, and my diagnostic prints work out fine. I declared the cardRank and the cardSuit, because I wasn't sure how to do it with just rank and suit for my card object.
This is my first time trying to use tokenizer, and trying to use an ArrayList, that is why I am having so many problems.
I consider myself a HUGE beginner, because I have only written about 4 other programs in java... but I felt I would get better help in this area in intermediate. Thank you for your help!
Jon
20 years ago
I am not sure how to add objects to an ArrayList. I am going to show some of my code, and could you please tell me, or lead me, in the right direction for how to do this. Thank you!

Okay, that was my object. Now, do I need to somehow return the rank and suit in my while loop? Okay, here is the BridgeHand class that neesds to get the cards added to it. (I thought it would be a good idea if the hand was in an ArrayList of Card objects...)

now, when I try to print the size of my list, it only says '1', so I know I am not doing this correctly, but I keep getting stumped at how to do it...
Sorry for such a long post, but I felt all the code was necessary for someone to try and help me out. Thanks a bunch ahead of time!!
20 years ago
Jim,
Thanks for the help. I didn't realize that I had to delete the class files. I thought recompiling would do that automatically. I went ahead and deleted, and recompiled, and now it appears to work like a charm! Thanks for the help.
Jon
20 years ago
Hmm... Line 41 in Card was this:

a println statement of what inputLine is, does not print anything if I place it right after that line.
umm...
this class is part of a larger class... do you think the error comes from somewhere in an earlier calling?
I didn't think it was appropriate to post the WHOLE program code that I had for this program. But is claioms to have the same null pointer error in all of my classes. at java.util.StringTokenizer. But when I have the print of cardRank and cardSuit, it prints out the proper output, so it seems to me it reads the line in, and processes each token properly.
Thanks!
Jon
20 years ago
Hey all... I have a loop to read a line of data in, then get tokens from the line and perform actions on those tokens. However, I'm not sure my reading in of data loop is correct, because after the processing of the data, I still get some errors. Specifically:
"Exception in thread "main" java.lang.NullPointerException
at java.util.StringTokenizer.<init>(Unknown Source)
at java.util.StringTokenizer.<init>(Unknown Source)
at Card.read(Card.java:41)"
here is the code that I have for this loop, if anyone can help me to tweak it, that would be great!!

Thanks ahead of time...
Jon
20 years ago
Hey all, I can't figure out why I can't seem to import the ArrayList class...
I am writing:

but I am getting an error message saying:
identifier expected

and then later, it is claiming that a '.' is expected after ArrayList like this:

What am I doing wrong? My Java book says this is proper sytax for the ArrayList class...
(have SDK1.4.2_03)
THANKS ahead of time,
Jon
20 years ago
Okay, thanks for the tip! Does this look like proper code for a situation for this?

or is this not legal usage of charAt? Can I parse it like that?
Any answers will be appreciated!!
Jon
20 years ago
I am at a lost as to where to begin...
I need to read data from a file (Example: 2c 4h 5d 9s)
then according to what letter is next to the number, I place in the proper
array spot. (So I am guessing multi-dimensional array?)
Umm... data is 13 'couplets' and I am at a total loss of where to begin. Do I need to use a string tokenizer, get one couplet, and then how do I tell from the couplet what letter it is.... I keep thinking this has to be simple, and I am just thinking too complex. I'm just not sure how to read mixed data types from a file (int/char pairs), and then how to figure out specifically what letter is from each pair. ANYWAY... ANY help at all on this problem would be MOST appreciated!!!
Jon
20 years ago