JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The reverse rate is just 1/rate, so you just need key(currency name) -> value (rate), and you can calculate the reverse rate on the fly.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

One case where I would use the constructor is where you have a mandatory immutable value. This will often happen when the value is used as a persistent ID in an underlying database. In that case I would declare the variable final and set it in every constructor.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Is this to convert bewteen any two currencies (eg GBP <> EUR, EUR <> USD, USF <> GBP etc), or just between different currencies and one "base" currency (eg EUR <> USD, GBP <> USD, YEN <> USD etc)? I ask because you talk of a currency as the key, not a pair of currencies.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Maybe this is revealing that the map[][] approach isn't a good one? If you defined ground as ab object like the movable ones, this would be easy?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In the first case, if you want to change the title of the jframe sometime later in your code ,you CANT change it . You have to create a new object inorder to change the title which is not what you need.

@harinath: Do you have any reference material or sample code to support this assertion?

You may want to run this:

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;

public class TitleChanger {

   static JFrame frame = new JFrame("Harinath says this can't be changed");
   static int counter = 0;

   public static void main(String[] args) {
      frame.setMinimumSize(new Dimension(500, 200));
      frame.setLocationRelativeTo(null);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setVisible(true);

      new javax.swing.Timer(3000, new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            frame.setTitle("changed " + ++counter);
         }
      }).start();

   }

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

When your question has been answered please mark your thread "solved"; don't just leave it pending forever. Thanks

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Don't worry, this one often catches beginners out!
You declare the method as returning a boolean, so the compiler checks your code to ensure that, no matter what happens in the if tests, you always return a boolean.
In your code, if all three if tests are false, you will get to line 94 without returning a value. You will need to add one more return statement to guarantee that you always return something.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If there's only ever 1 bullet then you don't need a list

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here's the usual way to do it:
in the bullet class have an update method (where you do x+=dx; etc)and a paint method.
Maintain a list of all the current active bullets, and make that list available to the main class.
In the main timer method call each bullets update method.
in the main paint method, call each bullets' paint method.

The simplest way to share the list of active bullets is to have a public static ArrayList<Bullet> in the Bullet class so any other class can access that list to iterate through the bullets.

If you are going to have different types of things moving around then you should consider having them all implement the same interface or inherit from the same abstract superclass (ie the update and print methods), then all you need is a single list for everything that moves.. j

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

For smooth movement, this is how people normally do it...
in your game loop (timer actionPerformed) you execute the camera_pos_x += camera_speed; and call repaint() every time. cameraSpeed is initially zero.
When the user presses the Right key, you set camerSpeed to +5. When the user releases the key you set cameraSpeed back to zero. That way the camera will move smoothly right for as long as the key is down.
You don't say how often your timer fires, something like 25/sec (40 mSecs delay) would be a good starting value.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The panel that needs to be repainted is display_class, so when you change any values in the simulation you need to call display_class.repaint(); to see the result.

ps I find your variable names quite bizarre - I hope they're not the result os some misunderstanding? Eg you have an instance of Display which you name display_class. It's not a class, it's an instance. It would make more sense if it was named displayInstance or theDisplay or somesuch. There's also a Java convention that variable names use "camel case" (like my examples) rather then underscores (except for constants that are all upper case)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you want integer values from Random you should use nextInt rather than rounding a random float - see the API doc for Random to appreciate the extra stuff needed to get good random ints.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Do you mean a number without leading zeros, or without any zeros in it anywhere?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

[Ljava.lang.Double;@35960f05 is what you get when you call toString() on an array of Doubles (which is what println does when you print anything - it calls toString() to get a printable version). That toString method is inherited from Object.

There's a method in the Arrays class that converts arrays to the kind of string you want -
System.out.println(Arrays.toString(myArrayThatIWantToPrint));

jspence29 commented: That worked Thanks! +2
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Ona completely separate point - you seem to be using a jaax.swing.Timer to run your game loop. Your architecture for this (separating the game loop from the screen painting) is exactly right, but that's not the best Timer for this purpose. The swing Timer will run your game loop on the swing event dispatch thread, where it will compete with the screen painting. If you use a java.util.Timer your game loop will run in its own thread, simultaneously if you have a dual processor. That wil allow you to achieve higher frame rates and smoother animation for no extra effort.
The syntax for java.util.Timer is slightly different, but it should only take a minute or two to change the code over.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That message doesn't seem to match the code - can you please copy/post the exact complete error message(s)?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

To fix the problem at its source convert the image file to a format that supports transparency, eg GIF and use an image editor to select end delete the background .

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That question makes no sense. You have misunderstood what a time zone is. DST is not a timezone, it is part of the definition of a time zone. Here's an example from the API doc

you can get a U.S. Pacific Time TimeZone object with:
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");

You seem to think that Los Angeles somehow changes its timezone every spring and autumn? The America/Los_Angeles timezone includes daylight saving time in the summer. The TimeZone object knows all about that. What flexibility are you asking for? The short answer is "no, you do not have the flexibility" because the governemnt has defined how DST works for America/Los_Angeles, its not up to you.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You specify the time zone (a geographical region), Java uses the appropriate time for that place, automatically adjusting for DST as specified in the DST info for that time zone. You don't need to do anything about it - it's automatic, based on the relevant dates.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

A TimeZone definition includes the DST. Did you read the API doc - it explains all that.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Look in the list of valid IDs using the code I posted earlier.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What's wrong with "EDT", "CDT" and "PDT"?

See previous post!

TimeZone theTmz=TimeZone.getTimeZone("PDT");
System.out.println(theTmz.getID());  ->  "GMT" // GMT is used when the TimeZone is invalid

It seems the JavaDoc means exactly what it says. You should be using proper time zone ID's. You can get a list with System.out.println(Arrays.toString(TimeZone.getAvailableIDs()));

http://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Maybe your problem is with those particular 3 letter codes.Have you tried "UTC","PST","GMT","PDT","AST" ?

The JavaDoc for TimeZone says:

Three-letter time zone IDs
For compatibility with JDK 1.1.x, some other three-letter time zone IDs (such as "PST", "CTT", "AST") are also supported. However, their use is deprecated because the same abbreviation is often used for multiple time zones (for example, "CST" could be U.S. "Central Standard Time" and "China Standard Time"), and the Java platform can then only recognize one of them.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

System.out.println(GetTimeString(null, null, "PST")); -> 03/22/2013 08:12:08
System.out.println(GetTimeString(null, null, "UTC")); -> 03/22/2013 15:12:55

That looks to me like it's working perfectly

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What does line 8 do? Where do all those variables on line 9 come from?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Can you re-post the relevant bit of code where you check for existing and set the new bounds?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Your target panel now seems to add the dragged item to the panel, regardless of where it was dragged from. So for an "internal" drag it will get added again. In the earlier version of the code you seemed to using a list of added items in an attempt to avoid adding the same item twice. That seemed like a reasonable thing to try. Have you abandoned that approach? Alternatively, if the drag starts with an existing OnBoardItem you could record that info somewhere and use that to change the bounds of the existing item rather than adding it again?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

... but anyway, c3 is the end of the chain, you didn't define a "next" for it, so on line 39 chain will be null... -> exception!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

" I get an exception"

We're not going to guess what that could be. Exactly what exception at which line? - copy/paste complete message

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK. printf is like print or println but lets you specify format info for the data you are printing, such as field width, no of decimal places etc. There's lots of examples and syntax on the web.
(I'm finishing now until tomrrow)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Do you mean like overwriting one line in the file or something like that?
Easiest way is to read the file into a String[] then update it, then write it all out again.
Or do you mean in fixed format, in which case printf is probably your best freiend

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The Integer class has a parseInt method to convert a String to an Integer, similarly for Double etc

edit: (Too late - you already got it)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have your data on ines 25,26 and you have an example of how to write those to an output stream on line 28. The output file stuff is a mirror image of the input file code you already have, so:

create a FileOutputStream for data2.text
create a PrintWriter using that FileOutputStream
print your data to the PrintWriter
close the output file

Check out the API documentation for FileOutputStream and PrintWriter, and look at the "line oriented IO" section here

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

Rather than add more variables so SeatsTest can double-guess what's in Seats, it would be better encapsulation to add one public method to Seats like
public boolean planeIsFull() {...
then in SeatsTest you just call that method whenever you want to know if the plane is full.
The implementation of that method now doesn't matter a lot (you can always change it), but I would just scan the array of seats - as soon as I see a vacant one I can return false, if I finish looping thru all the seats I return true.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Scanner is = new Scanner(new File(filename)); // works
is = new Scanner(filename); // does not work

API doc says :
public Scanner(String source)
Constructs a new Scanner that produces values scanned from the specified string.
Parameters: source - A string to scan

ps It's really time to stop using a thread about Comparators as a dumping place for every Java query you have. Please start a new Thread for each new topic.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

new ImageIcon(...) is famous for not throwing any exceptions when it fails to find the file; it's just empty. JLabel is happy to accept null for its image icon, so the final result is no image and no error messages. We see that quite often in DaniWeb "help!" posts.
Use the exists() method of the File class with the path/name of the file to confirm that your program can find the file. Alternatively, check the width/height of the image to confirm they are >0

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have made everything in LinearEquation static. That's wrong.
You create instances of LinearEquation, and each instance should have its own instance variables and instance methods. Simply deleting every use of the worde "static" from that class will fix it, but in the meantime you should revise your course materials on static vs instance variables and methods, or read this
http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

userChoice is set to the prompt "\nYou have selected etc, then you take the first char of that ('\n'). The user's input is in the variable action, but you don't use that. A good example of why names matter?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

the slope and b methods are ordinary instance methods of the Line class - so no need to pass in a Line parameter - just return the b or slope for the current object (this).

equals(Line that) is perfectly OK, for any other kind of parameter Java will use the inherited method from Object, which will return false.

Because you are using floating point numbers you may want to revisit those comparisons, you're aasuming an exact == will be possible, when maybe the best you will get equal-within-n-decimal-places kind of equality.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You will develop your own naming style, anything that conveys the right meaning to someone else seeing your code for the first time. I would use maybe "inputChar" for the char variable that holds the first (only) char from String userInput. Don't get too hung up on it, not everybody is quite as obsessed as I am about naming ;)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You need equals as well (should be equivalent to compareTo returning 0) so you can use useful Collections such as TreeSet. If there's no obvious meaning for > and <, then just return +1 or -1 in any consistent kind of way. You can always change that later if you find a real need to order Lines.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Fair enough. Personally I would call that variable "userInput" in that case, but then I'm a fanatic for good naming of variables and methods, and frequently change the names in my own code to make it clearer.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

One idea would be to keep a Line's Points in sorted order then you could compare two Lines by comparing their points in a loop one at at a time - if all the Points are equal then the Lines are the equal.
A totally different approach would be to calculate the slope and intercept of each line from any two of its points, then two lines are equal if they have the same slope & intercept.
Which you use (or maybe something else again) depends on exactly what YOU intend to mean when you say "these two lines are equal" - ie is that because they are defined by the same set of points or because if you draw them one will be exactly on top of the other?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Always use another variable. They cost you nothing, but you can give each of them names that fully describe what they are. Reusing one variable for two different purposes makes the code really confusing (see previous discussion)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I didn't mean to suggest that the project was out of control, just that it's partly exploratory in nature, and who knows where exploring may lead?

Yes, Arrays.equals isn't exactly broken (it complies with its own documentation), but it probably won't do what you want. I'd go with implementing Comparable, or at least equals, in your Line class.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Since nobody seems to know exactly where this is going, I would aim for clear, open, and extendable, rather than "just good enough". My instinct here is for

class Line { 
   private ArrayList<Point> points // 3 or more points defining this line
   public addPoint(Point p) etc
   public compareTo(Line l2) // equal if have same Points, even if order is different
   etc etc
}
...
ArrayList<Line> foundLines ....
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If your initial queston is answered then, yes, mark this solved. You can always start a new thread if ypu have a new question.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes. I have that right now (Eclipse with Java 7 and Netbeans with Java 8 preview)

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.