Bill Stanard

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

Recent posts by Bill Stanard

Thanks, Keith... Looks good and compiles, but I get an error when I run it


Any suggestions?
18 years ago
In preparation for a computing contest here in So. Florida, I'm trying to figure out a simple method to read a numerical data file into an array so that I can then massage the numbers in various ways. This has turned into a daunting task because of unicode issues. The data file looks like this

where 0 signals an end of file. I can get the file contents to print out just peachy (in the standard output, bottom output box, using JGrasp), but I cannot find a simple way to load this data file AS INTEGERS into an integer array.
I load the array as follows:

What loads is as follows:

This has been printed out with the following:

I understand that what is being loaded is unicode for 5 [53] followed by the equivalent of a new-line [13 10] followed by unicode for the next 10 integers, et cetera. What I would like to do is to populate the integer array with the integers from the data file.

Any suggestions?
18 years ago

Bill, some of the things in the list don't logically qualify as classes, e.g. shuffle, deal, discard, draw. Notice that these are all verbs. The nouns are better candidates for classes, e.g. card, deck, score.

Some candidate classes might be: Card, Deck, Game, Dealer, Player, Hand, Shuffler.



Aahhh... I think I need some direction in how to think about classes, methods, et cetera. Can you (or any of the helpfull folks in this neighborhood )suggest a book that might set me thinking more logically about the Java structure. I very much like the linguistic approach you seem to be suggesting and would like to pursue that...
19 years ago
Good question, Junilu. Less than satisfactory answer: I want to create a card game project for a group of students, so I want to break out a series of methods into separate classes (card, deck, shuffle, deal, discard, draw, score, et cetera).

I have been having the devil's own time calling classes that contain methods to use in this manner. I'm obviously making some fundamental error, but I don't seem to be able to figure it out. I can write the entire card game in a couple of classes, but I can't split it into a larger number of classes. Is there a project that you all know of that demonstrates the kind of interlinked series of classes like my projected card game that will give me a picture of how I must structure these classes?
[ December 05, 2005: Message edited by: Bill Stanard ]
19 years ago
Thank you, Henry.

When I run the following


I then get the following error:

which seems to me to say that a DeckOfCards object cannot be "processed" by the riffle method

even though the method clearly calls for a Card argument. Is the DeckOfCards that riffle( ) cannot be applied to possibly NOT a Card[] object. If not, (a) what is it? and, (b) how do I have to declare the riffle method to achieve the shuffle desired?
19 years ago
I have created a class named DeckOfCard.java which creates a deck of cards (using a class named Card.java) and then shuffles it. This class includes a method to deal cards from the created, shuffled deck one at a time. What I want to do is split out, into a separate class, the shuffle method. I know that I�m missing something simple, but I keep getting a compile error. Here, first, is the one-file (single class) code for Card.java:

Here is the DeckOfCards.java code, the single-class create-shuffle-deal class:

My question is this: If I want to set up Shuffle.java as a separate class and use its method to shuffle the deck created in DeckOfCards, how do I have to configure Shuffle.java and how do I have to call its shuffle method? Here is what I wrote for a shuffle class:

Here is what I wrote for a test class (with the non-working call commented):

When I comment out the shuffle method in the original code and then run the Test.java with the Shuffle.riffle( ) call, I get the following error:
Test.java:10: riffle(Card[]) in Shuffle cannot be applied to (DeckOfCards)
Bottom line: splitting out the shuffle code to a separate class and calling its method, named riffle( ), from test is a no-go. I know it is something simple, but its obviousness escapes me.

[ December 02, 2005: Message edited by: Bill Stanard ]

[ December 05, 2005: Message edited by: Bill Stanard ]
[ December 05, 2005: Message edited by: Bill Stanard ]
19 years ago
Thanks, Ernest & Layne,
It works... but... I need to grab and then resize the frame before it shows anything (in the case of the WelcomeApplet, the helloLabel). Any idea why this is? I've noticed it a lot with some of the applets I write, that text fields or labels are quite often hidden until the applet (frame) is grabbed and resized. Then all is well.
cheers!
Bill
19 years ago
Assuming a simple applet such as the following...

...where do I add the code that you suggest? Or do I rewrite my code to fit the pattern that you suggest? Sorry to be so thick...
19 years ago
For my programming students, I'm looking for non-applet (and non-JApplet) science simulations written in java. Most simulations seem to be in applet or JApplet format. Any suggestions on where to look for simulations that would be interesting to programmers and science (physics, chemistry, biology, et cetera) students?

cheers!
Bill

<[email protected]>
19 years ago
Thank you, folks, both for listening and giving such good advice. Updated the JRE to 1.5 (or is it 5.0?) and all ran beautifully. Had to change the file name from xxxx.zip to xxxx.jar, but that is small cheese. Again, thanks...
cheers!
Bill
19 years ago
The (working on my machine) manifest file points at MBSGUI as the file with the main method. I used the following command to execute the MBSimulation.jar file:

java.exe -jar MBSimulation.jar

The error thrown is as follows:

java.lang.UnsupportedClassVersionError: MBSGUI (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main"

Does this help?

cheers!
Bill
19 years ago
Running a .jar file (as an executable) on my machine (where I run JGrasp with the SDK loaded) I have no problem. When I post the .jar on my intranet server and download it to a machine where I have only the JRE installed, it is seen as a .zip file and gives me the error message "Could not find the main class. Program will exit" when I double click it, even after I change the name from xxxx.zip to xxxx.jar.

I think that the manifest file is correct because the .jar runs ok with double-clicking on the "full java" machine. Any suggestions?
19 years ago