JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have moved the arrays into ClientProgram. This makes the "collection" class pointless and is definitely a design mistake.
You application should contain exactly ONE array of Films, and that should be in the collection class. Every version of the code you post seems to contain at least two or three arrays so nobody (including you) ever knows which one has what data, and which one to use. One last time: exactly ONE array in the whole application.
In your ClientProgram class create an instance of the collection class. Use that one instance (and the one array of Films it contains) for everything.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

line 14 - you copy largest to nums - that's the wrong way round

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How exactly do you describe your problem? How does the output differ from what you expect?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Having a variable called "count" is confusing - is it left over from a previous exercise?
To find the largest you need a variable called "largest" which is initialised to a small value.
Then as you process each input you ask "is this bigger than largest" and if so, save that value as the new value of largest.
When all the numbers have been processed print out largest.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

but how can i get the array from another class file?
the ClientProgram is the Main, in fact i should take all the value from that collection class that array if got add films. :/

In your main class create an instance of the collection class (not an array!). Use that one instance (and the one array of Films it contains) for everything.

ps. As per the hiddepolen's post it is a helpful convention that Java class names always begin with a capital letter and variables and methods begin with a. lower case letter, but don't change collection to Collection because that's an important class in the Java API. A name like FilmCollection would be ideal.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

First looks OK to me - what is it doing that's wrong?
Last sets position to -1, that's not valid. Shouldn't it be productArray.length - 1?
Previous is testing for position at the end of the array (it's a copy of the logic for next), shouldn't this be testing for position at the start of the array (position == 0) ?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK then. that array is the one you should keep. I don't believe you need any of the others.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'm a bit baffled by the number of arrays in this program.
I would expect to see the collection class containing just one array of films, not two, and I would not expect to see any other class having any arrays of films or arrays of collections at all.
With all those spare/duplicated arrays it's not surprising that some of your code is coming up empty - it's probably trying to use an array which is not the one with the real data.
My best advice is that you should delete one of the two arrays in collection, and all the arrays in all the other classes. In the main class create one shared instance of collection. Then go through the resulting slew of compiler errors replacing all the references to removed arrays with references to the same one instance of collection.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, in general I agree. In this particular case it's less important because that final return can never be executed.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Your problem is that although you know that one of those if tests must be true, the compiler isn't quite that smart, so it worries about the case where all 3 if tests are false and execution drops out of the last elseif. In that case it gets to the end of the method without returning a String. ilovejava's solution will fix it, or, if you want to keep the very explicit version of your if tests you can just add a final return ""; at the end of each method.

ps @ilovejava - that was a sensible solution, but you will help people even more if you give some explanation of what the problem was caused by, and how your solution fixes it. J.

xiangzhuang commented: thanks +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can add labels to a null layout - you need to call setBounds to specify both the position and size, and request a repaint afterwards. For ultimate control over layouts while retaining all the advantages of a layout manager use GridBagLayout. The learning curve is a bit steep, but it's worth the effort.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

which mean the display all null to me, is not display the value that i've assigned.

Let's get serious now... that sentence tells me NOTHING. I don't know what exactly you are trying to display, or where you are trying to display it, or what code you are using to try to display it with. How can I possible comment without all that info?
If you want help with code that not doing what you want you MUST be very precise and very complete in describing exactly what the problem is and which code is involved.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I have no idea what "wrong information displayed" means, exactly. What wrong info, where how?
Yes, that's what I meant.
Why do you want to call the 4 parameter constructor from the () constructor? I can't see any reason for you to do that. Anyway, if, in general, you want to call another constructor from inside a constructor (of the same class) you use the "this" keyword, eg

class XXX {
   XXX() { ... }  // no-args constructor
   xxx(int i) {   // one arg constructor
     this();      // executes the no-args constructor for this class
     ...
   }
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

arrFan[0].FAST tries to use an array element that you haven't initialised yet, so that's why its null.
But that's not what I just posted! Inside any class other than Fan itself, you must refer to those static variables as Fan.SLOW, Fan.MEDIUM and Fan.FAST.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, no problem.
In the same class you can just use SLOW etc just like any other int, as in speed = SLOW; or if (speed == SLOW) ... In any other class you have to use the classname as well so Java can find it, as in Fan.SLOW

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, just add them one at a time and forget the second array.
You already have code to find an element and flag/unflag it - so what's the problem you are asking in bold above?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What's the question about the speed var? What you are doing now is good. Also your default value is good. No problemo.

ps: Those 3 speeds should ideally be an enum. If you have not covered enums in your course then ignore this comment!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK you lucky people - here's the first public outing for JC's instant "how to start a thread as simply as possible" tutorial.
1. You have a method doStuff() that you want to run in a new Thread.
2. Threads need a class that implements Runnable (ie with a run() method) to define what needs to be executed in the thread.
You can do that with a simple inner class:

Runnable myRunnable = new Runnable() {
         public void run() {  // the run method...
            doStuff();        // .. just starts your doStuff method     
         }
      };

now you can create a Thread with that Runnable

Thread myThread = new Thread(myRunnable );

finally you just have to start the thread executing

myThread.start();

that's all folks!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Avoid all the complicated threading options and just do it one of the two simple ways as described in
http://download.oracle.com/javase/tutorial/essential/concurrency/runthread.html
it doesn't matter which you chose. Either way its just a few lines of code.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, it must run in its own thread in that case.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I haven't read all that code, but...
it looks like waitMessages loops indefinitely, so when you call it it never returns, so nothing after it gets executed. Maybe it needs to run in its own thread and you just start it from the constructor?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry, but all these code fragments, without the actual data, don't really help.
I suggest you put a few print statements into your for loop to confirm the actual contents of the list and all the working values as the loop is iterated.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This link
http://stackoverflow.com/questions/1248510/convert-string-to-keyevents
includes a brute force switch to do the conversions. Not pretty, but probably your quickest & easiest option.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Are you confident about the isHit method? As long as isHit returns true for the first element in your list, this code will always set mutual = 0 and exit the loop

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Planet[] arrayPlanet = new Planet[4];

creates an array with slots for four Planets, but all those slots are originally empty (null). You need to initialise them with actual instances of Planet, eg

arrayPlanet[0] = new Planet("Venus", 255);
arrayPlanet[1] = new Planet("Mercury", ... etc

Now you can get rid of your p2, p3 etc variables and use the array instead, and get rid of all the if tests inside the loop. eg

System.out.println(arrayPlanet[i].calculateAge(age));
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, just checked out the import static - it does work for public enums in a public class, but you can't import anything unless it's in a named package, so
import static myPackage.Card.*;
will let you use the enums without qualifying their names, as I'm sure ~s.o.s~ knew all along.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have been presented with two options:
1. Declare the public enums in their own .java files so you can refer to them by their simple names in your other classes in the same package.
2. Keep them where they are, declare them static, and refer to them via their qualified names Card.Rank and Card.Suit (*). ~s.o.s~may have also been suggesting that you could use import static Card.* to make the enum names directly usable in your other classes - I haven't tried that myself, although I know it does work for ordinary public static final variables.

(*) that means all uses of the name, eg lines 11 and 13 there are two uses each, but you only qualified one of each

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What kind of object do you think that could be? How big do you think it could be?

Java 7's NIO package includes a MappedByteBuffer class that maps the contents of the file to a logical array of bytes (or other primitive types) in memory, but you do have to deal with managing which parts are in memory at any given time when the file is large

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Your enum is defined inside the card class so you need to qualify its name to use it. Better/easier is to move the enum declaration to be outside the card class.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Wow. That's dedication. ;-)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's because the print statement is outside the loop. The loop goes from line 121 to line 127, and iterates without printing anything. When it exits the loop it goes on to line 129 where it prints the last result.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you construct that flowchart diagram the hard way, or do you have a tool to help? I'm no fan of flowcharts in general, but sometimes they are very useful to explain a logic flow problem/solution, as in your example.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

...If I would NOT have made this try/catch block, and the error would have been thrown, the entire program would crash ...

Fortunately it's not quite that bad. The compiler checks that you have code to handle such Exceptions (either by try/catch or by passing it up to the calling method) and will give you a compile error if you haven't done enough. The error tells you which Exception you have to deal with, and where, so it's not too hard to fix. So the compiler won't let you continue with a program that can crash like that.

ps: yes, expert reader, I know about unchecked exceptions, but IMHO this is not a good time to confuse the issue.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The problem lies whenever I try to access dungeon in the DungeonRoom object the player is in

What does that code look like?

Is it possible you are accessing the dungeon array from your current DungeonRoom frather than that in the "parent" HostileArea? That would explain lack of error messages but no output.
If so you need DungeonRoom to have an instance variable for the HostileArea it's part of, and you can pass that in to the constructor for DungeonRoom when you create them following line 28.

It's perfectlt legal, but quite confusing having HostileArea as the superclass of DungeonRoom, but also a instance of HostileArea containing instances of DungeonRoom. Does DungeonRoom really have to extend HostileArea?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's quite common for a beginner to put everything static - it's because they start coding in the public static void main(String[] args) method, and immediately discover that they get compiler errors if the members they reference are not also static.
More experienced Java developers tend to have a main that just instantiates a small number (eg 1) of important objects, and hands over control to a method in one of those.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

To go beyond the standard look and feel components you have to replace their "paint" code with painting code of your own that draws them explicitly using lines,rectangles, ellipses and more complex shapes. Exactly how/where you do that depends on how clever you want your panels to be, but whichever way you are involved in a lot of pretty detailed graphics drawing methods. Have a look at these for a flavour of the kind of methods you'll need
http://download.oracle.com/javase/7/docs/api/java/awt/Graphics.html
http://download.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Short answer: yes.
Longer answer: Java's GUI classes ("Swing") are more aimed at standard business applications, with a standard look and feel. Your panels will be pretty straightforward if you accept one of Java's standard looks. On the other hand you can draw shapes and images any way you want to get any exact appearance you desire, but that's more work.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hashmap uses the key object's hash (an int as returned by the hashCode() method) to create the map between key and value. The default hash method that you inherit from Object returns unique values for every object, but you want to "equal" phone numbers to have the same hash so they will correspond to the same entry in the hashmap. In your phone number class you just need to override the default hashCode method with one of your own, as shown in the previous 2 posts. You may also need to override the default equals method similarly

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yup, I think you will have to override the hashCode and equals methods for your phone number class, but that's not too hard. Eg: you could convert the number to a String in a standard format, and then use that String's hashCode
(as per previous post, but return
unique.hashCode();

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The confusion here is two meanings for "addFilm". The collection class needs one, just like I described. But in your main class you also have a method (the one you just posted) that prompts the user for data for a new Film.
Personally I would re-name that to public void inputFilm to avoid confusion.
So inputFilm prompts the user, creates a new Film object, and calls the collection's addFilm(Film f) method to add the new Film to the collection.
(I'm going out now, bye for now).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
public class collection {
  private entity[] films = new entity[100];
  public void addFilm(entity film) {
    films[nextAvailableArrayElement] = film
  }

Your collection already has an array of films ("entity" is a silly name; they are films) so you don't need anyone to supply one. Just pass in one film and let the collection class add it to the array it's already got

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You don't.
You create a new instance of collection, and you call its public methods to add a film etc etc. The entity[] array is part of how the collection class works, and should ideally be private.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The contents of a for loop can be a statement or a block. Either way the contents are executed as many times as the (initialize; condition; increment) specifies.

for (initialize1; condition1; increment1)
    for (initialize2; condition2; increment2)
       statement;

Here the first for executes the following code as many times as it should:

for (initialize2; condition2; increment2)
       statement;

which inturn executes statement appropriately before going back to the outer for loop for another execution.
eg

for (int i = 0; i<3)
   for (int j = 0; j<2; j++)
      System.out.println(i + " " + j);

will give the following output
0 0
0 1
1 0
1 1
2 0
2 1

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Parsing this is easy. Split each line at the first : and drop the " marks. That gives you a load of name/value pairs that you can do with as you wish. Unless you are really that lazy...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's called image steganography , so Google those terms.
Here's a good article to start with:
http://mo.co.za/open/stegoverview.pdf

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, that's a good start! So what exactly are you stuck on?

(Please post your code in code tags next time - it's much more readable)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, you need an array of Films (or equivalent) in the Collection class, but not anywhere else. NB You declare it inside main so it only exists as long as you are in that method - it would be better declared in the class but outside any one method so all the methods of the class have access to it.

It errors because you didn't create an instance, like I explained earlier.
By making it all static you commit to one Collection array per program - static means "one per class". If you make it instance based then you can have multiple collections, and do good stuff like:

FilmCollection filmsIOwn = new FilmCollection();
FilmCollection  filmsIWantToBuy = new FilmCollection();

void buyFilm(Film f) {
   filmsIOwn.addFilm(f);
   filmsIWantToBuy.removeFilm(f);
}

ps Collection is the name of an important Java API class, so its best not to use it for your own class.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

DaniWeb Member Rules include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/forums/faq.php?faq=daniweb_policies

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You seem to have changed addFilm to be static, which is one possible way to get round the previous problem, but not the best way. Anyway, now you can ignore my last few posts.
As for the second array, I have no idea why you have it. I don't understand why you pass an array to a method called addFilm. I would have expected something like
public void addFilm(Film f) {...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It doesn't have any parameters.
It's like the String class has a toUpperCase() method. To call that method you need an instance of String, as in myString.toUpperCase()
You seem to define addFilm in a class called "collection" (very confusing - class names should begin with a capital letter), so you need to create new Collection instance and use that to call addFilm.
The compiler will give you a detailed exact error message. If you don't understand it then post it here; don't just say "i was unable to call the addFilm method"