JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Look at the pattern - all the rows are the same except
on the 2nd row the 5 is replaced by a *
on the next row the 4s and 5 are replace by an *
on the next row the 3,4,5 are replaced... etc

You can use an if test to decide for each position whether to print the number or an *

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Put the strings into an array and use the randon int (0-3) as the index to retrieve one element of the array.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can write a public method in class B that updates the table using new info that is passed in as a parameter. Then you can just call that method from class A passing the latest value from the combo box.
Class A will need a reference to the class B instance, but whoever creates the instances of A nd B should be able to provide that.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Are panels A and B defined in the same class, or different classes?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

enum Status{WIN, CONTINUE };
That's enough to define and initialise the enum, you don't need anything else.
What exactly was the comment that confused you?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just go back to the problem definition and work through it one step at a time. It's written so as to help you. Start with the array of booleans with index values 0-100 inclusive. (The size is defined in the problem statement, so you don't need it as a parameter.)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Use the String split method with a comma as the split character to separate the strings into a String array, then use trim() on each string to get rid of leading and/or trailing blanks as required.

Or, if you're a regex black-belt you could define the separator string as <any amount of white space><comma><any amount of white space> and do the whole job in one step.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

@godzab:
Please explain exactly how you think AtomicInteger is relevant here.

@47Pirates:
All you need is a simple listener that updates the table. Please post your latest/best attempt for further help.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes - it provides the default way to display a single instance of a Customer, so it's an instance method of the Customer class.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Looks like a problem with your toString - it should be in the Customer class, and look like
return getStreet() + getTown() ...
so it gives details of the current Customer instance

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, you can use a single reader just lik ethat. But every try must have its own catch.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You could do that. I would just have a List of Customers (or maybe a Map with customer.name as the key, and the whole Customer object as the value, so it's easy to find the right customer), and in each customer I would have it's own list of Repairs as an field.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Welcome.
We are happy to help anyone, beginner or expert, as long as they are willing to listen and put in some effort.

might not have been initialized

Means what it says. The compiler has worked out the possible routes through ypur program, and seen that one or more results in the var not being initialised before it's used. In this case it's probably what happens if a try block fails so the program goes via the catch instead. If you initialise them when you declare them this problem cannot happen - eg String firstNumber = "";

ps You don't need all those BufferedReaders - in fact they may cause problems by interfering with each other. Just have one reader and use that for all your input.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Start with a Customer class with fields for name, street etc rather than an unstructured set.
Then create Repair class that has fields for Customer, device, notes (etc)

You will find that the application will then be pretty easy to structure using those two main components.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The languages are very similar, but the APIs are completely different. Converting the syntax (with a few specific exceptions) is no big deal, but mapping/converting the APIs would be a massive task.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How do I put (File soundFile) as the parameters in new Track()?

If Track has a constructor that accepts a File as a parameter, then just create a File and pass it, ie

File f = .... create the file as needed
track = new Track(f);

If Track does not have a constructor that accepts a File as a parameter, then you will have to create that constructor first...

public Track(File aFile) {
   ... do whatever the constructor needs to do
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Can you post your exact complete manifest file here?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 1 is the start of the definition of a method called main. (Every program needs this method - it's the one that is called first when you execute your program). Then on line 3 you start the definition of another method. You can't define one method inside another. You have to close the definition of main with a } before you can start the next method.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

@cross213:
stultuske is giving you good advice, so you should make more effort to follow it rather than wasting his time. Your latest code completely fails to implement the perfectly good solution that he gave you earlier. Re-read his posts and think carefully about what he says..

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

pps:
for the "line 13" problem, you need to make a list of all the possible combinations of x0, x, x1, f(x0), f(x1). f(x), and a that you could encounter, then make sure that your if tests will either change xo or change x1 or exit the loop with an error, for every possible combination.
Suppose, for example, that value a cannot be found between x0 and x1? Suppose f(x) has a negative slope between x0 and x1? (etc)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

ps Have you confused the operator priority??

!A||B
is evaluated as
(!A) || B
it is not the same as
!(A || B),
which may be what you intended?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't see anything wrong with updating x0 and x1 like you are doing - more variables won't help. But there are two logic problems as far as I can see:
1. Your loop condition will always be true, regardless of what's in the loop. So your loop will always be infinite.
If f(x)!=a the condition is true, but if f(x)==a then abs(f(x)) will be zero, which is <= epsilon for all non-negative epsilons, so the condition is also true.
2. Line 13 is untrue. If you get to that else block then x0 and x1 will not have been changed, so the loop condition (even it that was correctly coded) would still be true. Line 13 should print "the loop is infinite", or do something to fix the situation.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, I really can't bear the thought of you having to resort to C++
Here's a tiny runnable program that shows wrting all possible byte values to a file, then readingthem in and displaying them as signed values, unsigned values, and characters...

import java.io.*;

public class ByteIODemo {
// simple demo of reading/writing bytes as unsigned ints or chars

   public static void main(String[] args) {
      // define a file in the current temp directory
      File tempDir = new File(System.getProperty("java.io.tmpdir"));
      File byteFile = new File(tempDir, "bytes.data");

      // write all 256 possible bytes values to the file...
      try {
         FileOutputStream out = new FileOutputStream(byteFile);
         for (int i = 0; i<=255; i++) out.write(i);
         out.close();
      } catch (Exception e) {
         e.printStackTrace();
      }

      // read all the bytes...
      byte[] theBytes = new byte[256]; // input buffer
      try {
         FileInputStream in = new FileInputStream(byteFile);
         in.read(theBytes);
         in.close();
      } catch (Exception e) {
         e.printStackTrace();
      }

      // interpret each byte as unsigned value and character
      for (byte b : theBytes) {
         int unsigned = b & 0xff; // mask out unwanted sign bits
         char c = (char) b;
         System.out.println(b + " " + unsigned + " " + c);
      }

   }   

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

There is absolutely no problem reading and writing bytes in Java, it's just that there a tiny gap in your knowledge somewhere that is preventing you from seeing the solution. You can read/write arrays of bytes with a single method call, and manipulate the bytes as numeric or character or just plain bits. If you can show what you are trying to do, eg in pseudo-code, then we can point you in the right direction.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

A byte is 8 bits, nothing more. You may chose to interpret that as a number, or as a character, but that's up to you. The simple read() method for input streams places those 8 bits as the least significant 8 bits of an int variable, where you can use them as a number or cast to char (although there are better read methods for text data that handle the conversion from different byte-oriented character sets to UniCode).
What exactly do you want to do with your bytes?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Looks like basics[i] is null for some value of i.
Print i and basics[i] at that point in the code to see which element is not initialised, them backtrack in your code with prints to see why/where the initialisation is missing.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, FlowLayout is not one to use for your requirement - it doesn't resize it just adds space before/after. Use a GridLayout, or go the whole hog and use a GridBagLayout for total control

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Are you using a layout manager? Layout managers ensure that your forms can re-size as required, eg when moving from one OS to nother with completely different font sizes. They come in various flavours, from very simple to you-can-control-everything-in-great-detail. See
http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes. Now combine those two pieces of code and you have your solution.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Good start, but inside the loop you have an array that you also need to loop through - ie you need 2 nested loops.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's because whiteBoardapplet doesnt implement it. It's ABHandler that implements it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

PriorityQueue uses a private array to hold the queue. It automatically re-sizes the array when needed. By specifying an initial capacity you set the initial size of that array. Its just an optimisation thing - if you know how big your queue will be then the array can be made just big enough without needing to be re-sized. But it is just optimisation - the result of ruunning the program will be the same regardless. It may just use a little less memory, or run a little bit faster. Igniore it.

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"

What have you done so far?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 91 you call getWidth() without an explicit object, so that's the same as this.getWidth().
"this" is the current instance of JavaApplication12, which extends JFrame and inherits getWidth() from it. So 132 seems like a perfectly reasonable value.
You will see a different result if you call ant.setVisible(); rather than making and displaying a new instance of JavaApplication. In that case you will be looking at an instance of Creature, with its own getWidth. However, by overriding set/getWidth from JFrame you may screw up the size of the frame.
IMHO making Creature a subclass of JFrame is almost certainly a bad idea.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

... and you're certain that that declaration isn't being masked anywhere?
OK. Try printing the inStream.readObject() at that point to see exactly what kind of object you are getting

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That seems to suggest that players is declared as a String - you haven't posted it declaration.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Normally you would use a Listener to respond to changes in the table's data, and feed those into SQL statements to update the database. The details depend on exactly how your overall systeem is put together, but you will find many relevant examples on the web.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There's no code there that can update the database, so how exactly are you trying to update the values?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

^ basically right, except that nowhere does Java define any mapping between 0 and 1s vs the boolean values false/true.
Bitwize operators work on each bit of an int value, the logical operators work on individual boolean true/false values, but there's no connection between these two versions.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

With Java Swing you can use your own buffering and timing threads, but it's better to use the highly optimised and integrated Swing timimg/buffering that are made available to you. Here's a trivial but fully runnable program that shows how these fit together to animate a box moving across the window, it's the basis of the "standard" approach to Swing animation

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

public class MiniAnimation extends JFrame implements ActionListener {

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

   private int xPos = 0;

   MiniAnimation() {
      super("Minimal Animation Demo");
      setMinimumSize(new Dimension(300, 200));
      setLocationRelativeTo(null);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setVisible(true);
      new javax.swing.Timer(50, this).start();
   }

   @Override
   public void actionPerformed(ActionEvent arg0) {
      xPos += 1;
      repaint();
   }

   @Override
   public void paint(Graphics g) {
      super.paint(g);
      g.fillRect(xPos, 50, 100, 100);
   }

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

I just had a quick look, so maybe I missed something , but anyway...
The original correctly uses a Timer to call its actionPerformed method at regular intervals. That's how the animation is updated and finally repaint() is called to tell Java that the screen needs to be updated. (Java will then call the overridden paint(Graphics g) method.) I don't see the Timer in your code - a single sleep isn't remotely equivalent.
It's a classic beginner's mistake to code hundreds of lines before running any tests to check if the basic ideas are right. I recommend that you set this aside and write a minimally short program that uses a Timer to move a simple rectangle once across the screen. That will give you an understanding of the Timer, the actionPerformed method, and the paint method, and the relationship between them. Then you can go back to your more complex code and you will know what you are doing.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
  1. In a linked list the nodes are not numbered, so it makes no difference whether you chose the count from 1 or 0 as long as you count the correct number of total entries in a consistent way.
  2. Each node in a linked list contains an Object, and a reference (pointer) to the next node. The "head" variable usually contains a reference to the first node, which contains an Object, and a reference to the second none (etc).
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

FYI my Win 7 JDK/JRE installation didn't set any program association for .class files, just .jar's

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Probably becuase v2 is zero on line 24. Perhaps you should be setting v2 somewhere?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Java is multi-platform, so you can't assume that the OS will support files >2GB

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Can we create a text file of the size specified by the user?

Yes. Just ask for the size and write that number of bytes to a new file. For large amounts of space it may be safer to create a new directory and fill that with 1GB files, rather than have one file > 2GB

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

An integer literal is of type long if it ends with the letter L or l; otherwise it is of type int. It is recommended that you use the upper case letter L because the lower case letter l is hard to distinguish from the digit 1.

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's println (short for print line). You have a capital I for India instead of a lower case l for Liverpool

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

ps
If you import static the class then you can use its static methods without prefixing the class name
ie

import static java.lang.Math.*;
...
x = cos(y);  // static method cos is resolved via the import static for Math
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In Java you do this by creating a utility class with all those functions defined as static (so they don't need an instance to be created). A good example is the Math class in the standard Java API
http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html
you can simply import this class at the start of your program, then call the methods like Math.cos(x) or whatever.