Mark Van Tuyl

Ranch Hand
+ Follow
since Mar 22, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mark Van Tuyl

If you're going to use an Iterator, that's fine.
If you're going to use a for loop to step through the List, that's also fine.

The problem is that you're trying to combine the two. Your while loop executes until the Iterator has no more elements, but you're never advancing the Iterator to the next element.

Also, your index within the for loop is set to either 0 or 1. You probably want to use i rather than 1.
[ November 09, 2006: Message edited by: Mark Van Tuyl ]
15 years ago
15 years ago
assert (game.numberOfPlayers >= 2 && game.numberOfPlayers <= 5);
15 years ago
Correct. If you have selected an invalid number, you must decrement the counter.
15 years ago
Create a variable to hold the previous term and initialize it to zero.
Add the current and previous terms to obtain the result and save the current term in the 'previous' variable.
15 years ago
Once a number has been selected, set it to -1 (or some other invalid value). Before displaying a number, make sure it's valid. Otherwise, select another.
15 years ago

Originally posted by Joanne Neal:
2. String.indexOf() - find the position of the last '.' and then use String.substring().

Just a suggestion - String.lastIndexOf(".") will find the position of the last '.' in the String.
16 years ago
What you've got will indeed define a new type of Exception.

I would suggest, however, that you include the call to super() in both constructors. Otherwise, when creating an instance of the exception using the default constructor, no specific information about the exception will be available.

You might do something like this:
16 years ago
You need to go into System and Environment variables and add
C:\j2sdk1.4.2_11\bin\
to the 'path' variable.

Alternatively, you can add
%JAVA_HOME%
to the 'path' variable.
[ March 18, 2006: Message edited by: Mark Van Tuyl ]
16 years ago
I have a few comments:

"Person extends Employee - Person is a Employee - not sure about this one is sounds like it makes sense but not sure though but I guess sicne not every person is a employee it would not work."

It works the other way around - every Employee is a Person.


"Ferrari extends Engine - Ferrari is a Engine - does not make sense but ferrair has a Engine so Ferrari would be a instance variable of Engine?"

Ferrari has an Engine, so Ferrari would implement the Engine interface.


"Container extends Jar - Container is a Jar - could make sense too since a Container could be a Jar."

But not all Containers are Jars. The reverse works: Jar is a Container so Jar extends Container.


"Beverage extends Martini - Beverage is a Martini -- this one to me could work too since martini could be classified as Beverage but then again not every beverage is a Martini."

Again, it's reversed - Martini is a Beverage, so Martini extends Beverage.
16 years ago
Here's an example of what I'm talking about
16 years ago
This looks kind of odd to me
The if statement attempts to retrieve a StudentRecord object from the array. It then attempts to compare the name in the object to the name provided. If they're not equal, it creates a StudentRecord object at that position in the array.

Why not make sure the object exists before trying to call a method on it?
16 years ago
I think you want to take a look at the InetAddress class.
16 years ago
I would use something like this:
16 years ago
If you always want to replace the last character, you could do something like this
16 years ago