JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I have considered eventually hiring an experienced programmer to fine tune everything...

Software quality (no matter how you measure that) starts with the specifications and is more or less fixed by the design. If the design is good you can deal with any rough code later, if the design is poor no amount of clever coding will fix it.
Conclusion? If you want to involve someone experienced, do it sooner, not later.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

@subramanya:
This is an exercise in the use of generics. All you have done is to remove the generics from his code.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Obviously you can't run the program if it didn't compile!
When you compiled the program it found an error and will have given you a detailed error mesage explaining what was wrong. What did that say?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Thread sleep isn't a good way to go, the Java API includes Timer classes that you can use to schedule updates to your animation at regular intervals. The paint looks OK. Here's the simplest possible runnable example of a good approach

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Animation0 extends JFrame implements ActionListener {
   // absolutely minimal example of how to structure animation in Swing.
   // One method that steps the simulation model through time
   // One method that updates the screen with the latest data
   // close window to exit.

   public static void main(String[] args) {
      new Animation0();
   }

   Animation0() {
      // build a minimal working window ...
      setTitle("Animation 0 (close window to exit)");
      setMinimumSize(new Dimension(400, 150));
      setLocationRelativeTo(null);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setVisible(true);
      // start Timer to call actionPerformed every 30 milliseconds...
      new Timer(30, this).start();
   }

   // this is the "model" - just a single object moving L-R at constant speed
   private int xPos = 0; // current position(s) of animated object(s)

   public void actionPerformed(ActionEvent arg0) {
      // reliably called by Timer every 30 milliseconds
      xPos += 1; // update position(s) of object(s)
      repaint(); // notify that screen refresh is now needed
   }

   // this is the GUI - draws the model on the screen

   @Override
   public void paint(Graphics g) {
      // screen refresh - called by Swing as needed
      // Never update positions etc here because there are no
      // guarantees about when or how many times this will be called.
      super.paint(g); // ensure background etc is painted
      g.fillOval(xPos, …
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

First a point of terminology: there's no such thing as an "anonymous outer class". Only inner classes can be anonymous.
Anyway, "yes" to both your questions. You have to create an instance of the outer class before you can create an instance of the inner class (unless the inner class is static, of course). An instance of an inner class has a reference to the outer class which it uses to access the members of the outer class, you can use that reference explicitly eg Airjet.this.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yup, it comes with experience.
You don't need to worry about methods having the same name. The API doc tells you everything about the methods for any given class, and that's all you need.
The exact details of how Java finds the right method is documented in the Language Specification, not the APi doc, but honestly I wouldn't worry about that just yet.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, int randomNumber = new Random(); is worse than useless, it won't even compile. A random number generator is not the same as an integer, so you can't just assign one to the other.

You can also use the same generator repeatedly for multiple random numbers, eg

Random generator = new Random();
for (int i = 0; i<10; i++) {
    // generate 10 random ints
    Sytem .out .println(generator.nextInt());
}

You will find many many examples in Java where two classes have methods with the same name. In general they will do something similar (that's why they have similar names), but the details will be completely different. Java is smart enough to see what kind of object you are using when you invoke the method, so it knows which version to use.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The Random class is a random number generator. It can generate all kinds of random values, eg ints, gaussian distributed doubles, arrays of random bytes etc.
new Random() gives you a new random number generator - not a randon number, but a random nunber generator. You then use that to generate random numbers, eg by calling nextInt for a random integer, nextBytes for an array of random byte values etc.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Unless you want to use the new Random again there's no need to create a variable

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

tHelloWorld.java is the name of a source file, not a class. Assuming you have compiled HelloWorld, and the .class file is somewhere in your classpath, all you need to do is o change line 1 so the string just contains the class name.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
For each element:
   if there is another element the same, remove it.
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I think you can safely ignore "callback" for now, just concentrate on writing the method.
Ant is an abstract class, so you will have to create one or more subclasses of Ant, each corresponding to a different type of ant. There also seems to be a String (called antType) that identifies each type of ant (ie which sub-class of Ant).
Presumably a player can only recruit certain type(s) of Ant, so you need to check the antType against som kind of data in the player that says what kind of Ant they can recruit.
I'm guessing a bithere, because I don't have the complete project spec in front of me, and wouldn't have the time to read it all even if I did!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

new Random() creates a new instance of Random, then we use that to call nextInt. So nextInt is an instance method.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you look at http://www.jthink.net/jaudiotagger/ - it looks pretty good and seems to support setting artwork. (I haven't tried it myself)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Oh dear! You caught me out there! I was being sloppy with my terminology and yes, I should have said literal. (In my defense we were discussing float vs double there, it was only later that we got onto constant vs literal.)
You're right. My fault. :)
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have a clue in how it's called - if its called using an instance then its (probably) an instance method. If it's called using a class name then its definitely static.
In the end you can always look at the API documentation which shows every method's details.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In the Lava Language Spec - the definitive description of the Java Language - the words constant and literal are used for two related but different meanings:
a "constant" is a field whose value cannot be changed
a "literal" is a value; it has no name, it just is what it is.
So in the code
final double PI = 3.14159;
PI is a constant, and 3.14159 is a literal.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Try javax.xml.bind.DatatypeConverter (Java SE 6 or later)
That has printBase64Binary and parseBase64Binary methods to convert byte[] to printable String and back again, eg

      byte[] b = {(byte) 99, (byte) -101};
      String s = javax.xml.bind.DatatypeConverter.printBase64Binary(b);
      System.out.println(s);
      byte[] b1  = javax.xml.bind.DatatypeConverter.parseBase64Binary(s);
      System.out.println(Arrays.toString(b1));
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You could convert them to Strings (eg in hex) then there's no problem with properties files.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The Oracle Java Tutorials are unbeatable, although they do require you to read carefully and think about it. Here's the one on data types:
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

... which packages should I import ... ?

For any Java API class, just Google for the Java API documentation for the class, and you will see the fully-qualified package name as the very first line. That's the exact thing you need to import.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, because if you code

float ff = 12.5;

the 12.5 will be a double constant, and Java will not automatically convert a double to a float becuase that looses precision. You will get an error "Type mismatch: cannot convert from double to float"

(ps: You can also use float ff = 1; because Java will automatically convert an int to float)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

"var" isn't Java, but anyway, in Java if you omit the "f", eg 12.5, it's assumed to be a double (same as float but twice as many bits for much greater accuracy).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can use the printf method instead of print. That allows you to specify formatting, eg how wide numeric fields should be.
http://www.homeandlearn.co.uk/java/java_formatted_strings.html

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

You read the file into the arraylist the search (OK), then search the arraylist for the desired value, but when you do that search you use the code for file reading (nextLine) rather than an ArrayList method to eccess the next element in the arraylist.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Where do lines 1,2 fit? You're obviously missing some of the code in that listing

OK, nevermind, heres the problem:
When you execute lines 1,2 you create new Main and call its createAndShowGUI() method, which, on line 56 creates a second instance of Main and displays that in the JFrame. NOw you have two instances, only the second one is visible, but both are executing

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Almost right - the validation needs to go before lines 74/75 where you put the data in the arrays.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

break is normally used for loops etc. To stop any further processing in a method, just call return; at the appropriate point.

Yes, you did ignore Norm's post "You should validate the data BEFORE putting it in the array." You put the data in the array on lines 74,75 then validate from lines 80 onwards. Norm knows what he is talking about.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you follow Norm's last post?
Maybe its time to post the current version of the code so we can see what you've done.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

They have just one value for the whole class, ie they are a single var that's shared by all the instances of that class. Lots more details in the tutorials...
http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Order is the class name. YOu use it to refer to static variables and methods of the class. If those are instance (non-static) methods then you need to call them with an instance of the class, eg filename

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's line 44 that's worng.
When you init your VectorGraph instead of adding that VectorGraph to the JFrame you create a second VectorGraph (with default values of 0) and add that instead. Your correctly constructed VectorGraph never gets displayed.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK. When you have an answer can you please mark your threads "solved" for our knowledge base. Thank you.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That just nulls your local variable. You need to tell the JLabel to use a null icon, eg:
myJLabel.setIcon(null);

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Maybe your problem isn't the clip, it's this horror on line 43

while(clip.isActive()){}

that's going to take 100% of the available CPU until it terminates
I suspect there must be a better way to be notified when a clip is finished, but at the very least you could try something like

while(clip.isActive()){Thread.sleep(250);}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just set the JLabel's imageicon to null

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If I understand the question properly...
If your objects just store the value of c, then the information about whether it was a+b or b+a will be lost, and can't affect anything afterwards. On the other hand, if your objects store the two input values (eg arg1 = a, arg2 = b for the first case, arg1 = b, arg2 = a for the second) then they can make that info available to other classes.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Woahthere! You misundertand me! I meant no insult, nor did I mean to discourage you. I was not offended, nor did I want to offend you. In no way was I suggesting that you shouldn't ask questions. I was just trying to alert you to a problem that's pretty common with people who are at just starting with Java. I was just trying to help you get the best out of DaniWeb.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK!
If you don't mind a bit more advice...
please be very careful about how you use Java terminiology, otherize you will confuse people and therefore possibly get completely misleading answers. For example:

have a separate constructor for each String type

I honestly don't know what meaning you intended with this. There is only one String type and that is String. String is a final class with no subclasses, so there can never be any other types of String. In any class definition you can only have one constructor with any given list of parameter types, so you can only have one constructor that takes a single String.

I'm noy trying to be picky here, just trying to ensure that you get the right answers to your questions.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I think the change you made is going in the wrong direction. If you have 2 objects each should have its own string, and doesn't need to know about the other object's string. What will happen when you have 3 objects, a thousand objects? Will you have a thousand string constructor?
Normally you would have a String variable defined in the class. The constructor would take one string as a parameter and use that to set the variable. That way every time you create a new object it automatically has its own new string.

A suggestion: If you use a real-life example rather than just abstract class names it will be a lot easier to see what makes sense and what doesn't. Eg: just change the name of your class to Computer and the name of the String to manufacturer. Now which makes more sense:

Computer a = new Computer("Apple");
Computer b = new Computer ("Dell");

or

Computer a = new Computer("Apple", "Dell");
Computer b = new Computer("Apple", "Dell");
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

72: nextStudent++;

You have the code to update nextStudent correctly, but there ate two related problems that prevent that working as you expect:
1. Every time you enter your actionPerformed the first thing you do is to set nextStudent back to 0
2. You declare nextStudent inside the actionPerformed method, so its just a local variable that gets discarded after each execution of the method. and a new one is created each time you enter the method, so it cannot possiby carry the value forward from one call to the next.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The original question seems flawed. As you say, square and circle each require one numeric parameter, triangles and rectangles both need two, so there's no way to distinguish those method signatures without resorting to highly artifical solutions like the one you show.
Are you certain that you were not asked for a polymorphic solution? Polymorphism would make perfect sense here, but overloading doesn't.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

A jar file is just a zip file with some standard contents, so you can open it and browse the contents with any zip program you like - winzip, 7zip, stuffit etc etc. You are looking for a manifest file that correctly identifies the class with the main method, and for a structure of folders that exactly matches your packeges, with all the class files (and any other resources you need) in the right palces.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you check the jar contents?
If you run a jar by double-clicking it uses javaw,exe which does not display the console, so you can't see any error messages. Try running your jar with java.exe so you can see any error messages

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Without actual error message(s), the code in question, and a listing of the jar contents it's very hard to identify where you have gone wrong!
One likely area is that some classes are missing from the jar, or are not in the correct folders within the jar, but the error message(s) would make that clear.
Give us enough info to work with please.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If the array starts from 0 and gets incremented twice then shouldnt every other element be null?

It's increnmented once on each pass of the inner loop (that's OK), plus once on each pass of the outer loop (which is where you get the null). Like Norm says, print the values to see whats happening.