Messages - alexp [ switch to compact view ]

Pages: prev1 2 [3] 4 5 6 7 8 9next
11
Java / Re: java applet problems
« on: April 24, 2006, 09:23 AM »
I know but I earlier on in the applet I have set the Desert class as a super class

//sets the Desert class as the super class
public Desert() {
super();
}

and in this class doesn't everytime I have main mean that I'm telling the code to look in the Desert class for the method?

final class ControlsPanel extends JPanel implements ActionListener {
   private JButton bReset, bRules, bSolution;
   private JPanel buttonsPanel;
   private Desert main;

   // constructor
   ControlsPanel(Desert main) {
      this.main = main;

                panel code goes here

   }

   public void actionPerformed (ActionEvent e) {
      if (e.getSource() == bRules) {
         JOptionPane.showMessageDialog(null, main.rules(), "Rules", JOptionPane.INFORMATION_MESSAGE);
      }
      if (e.getSource() == bReset) {
         int userResponse = JOptionPane.showConfirmDialog(null, "Are you sure you want to reset?", null, JOptionPane.YES_NO_OPTION);
         if (userResponse == JOptionPane.YES_OPTION) {main.newGame();}
         if (userResponse == JOptionPane.NO_OPTION) {};
      }
      if (e.getSource() == bSolution) {
         int userResponse = JOptionPane.showConfirmDialog(null, "Are you sure you want to see the solution?", null, JOptionPane.YES_NO_OPTION);
         if (userResponse == JOptionPane.YES_OPTION) {main.solution();}
         if (userResponse == JOptionPane.NO_OPTION) {};
      }
   }
}
so using the same thinking thats what I tried to do with the Jeep class, but for some reason it doesn't seem to work in this class.

12
Java / Re: java applet problems
« on: April 24, 2006, 08:09 AM »
 :-[ well it used to called this.main = main but for some reason I changed al the mains to deserts (don't ask me why :)) because the gameWon() method is in the Desert class but it doesn't seem to get called.

final class Jeep {
public String name;
public int petrol, distance;
private Desert main;

protected Jeep(String jeepName) {
petrol = 0;
distance = 0;
name = jeepName;
}

private boolean canGoForward() {
if ((distance / 40) <= (petrol - 1)) {
return true;
}
else {return false;}
}

    protected boolean forward() {
        this.main = main;

        if (won()) {
            main.gameWon();
            return false;
        }
        else {
            if (canGoForward()) {
                distance += 40;
                petrol -= 1;
                return true;
            }
            else {return false;}
        }
    }

    private boolean won() {
    if (distance == 120) {
//    if (distance == (9 * 40)) {
            return true;
        }
        else {return false;}
    }

13
Java / java applet problems
« on: April 24, 2006, 02:06 AM »
I'm sooooo close to finishing this Java applet I'm working on. I only have three things which I'm struggling to get to work.

#1 The solution

The user presses a button and the applet should run through the solution to the puzzle. I kinda have it working in so much as the applet seems to run through the solution but the display doesn't get refreshed until the solution is finished.
public void solution() {
int solutionSteps = 9;
        for (int i = 0; i < solutionSteps; i++) {
doSolutionStep(i);
try {Thread.sleep(1500);}
catch (Exception e) {e.printStackTrace();}
}
}

public void doSolutionStep(int step) {
int y = 0, z = 0;
switch(step) {
case 1 : {
for (int i = z; i < theJeeps.length; i++) {
forward(theJeeps[i]);
try {Thread.sleep(1500);}
catch (Exception e) {e.printStackTrace();}
}
for (int x = 1; x < theJeeps.length; x++) {
theJeeps[y].transfer(theJeeps[x]);
}
home(theJeeps[y]);
y++;
z++;
break;
}
case 2 : {
for (int i = z; i < theJeeps.length; i++) {
forward(theJeeps[i]);
try {Thread.sleep(1500);}
catch (Exception e) {e.printStackTrace();}
}
for (int x = 1; x < theJeeps.length; x++) {
theJeeps[y].transfer(theJeeps[x]);
}
home(theJeeps[y]);
y++;
z++;
break;
}
I don't see why the display shouldn't get refreshed as I'm calling the forward method which refreshes the display so I assumed that everytime the forward method runs the display would get refreshed.

#2 When the user completes the puzzle it's supposed to pop up a dialog box with a congratulatory message. However I can't seem to figure out why it's not working.
    protected boolean forward() {
        this.desert = desert;

        if (won()) {
            desert.gameWon();
            return false;
        }
        else {
            if (canGoForward()) {
                distance += 40;
                petrol -= 1;
                return true;
            }
            else {return false;}
        }
    }

    private boolean won() {
        if (distance == (9 * 40)) {
            return true;
        }
        else {return false;}
    }
The IDE I'm using (eclipse) flags up the line desert.gameWon(); with the following error: The assignment to variable desert has no effect which I guess is why it's not working but I don't really understand why/how.

#3 The IDE is flagging up all the classes with the following messages: The serializable class (name of class) does not declare a static final serialVersionUID field of type long I'm not really sure what this means, it doesn't seem to be affecting the running of the applet.

I have attached a zipped copy of the applet & please be gentle with me as I'm still learning Java :D

14
Find And Run Robot / Re: Alias sharing
« on: March 28, 2006, 12:52 AM »
OK call me stupid but exactly how would I go about implementing these into f+rr? I know you have to go to the groups tab and create a new group but then exactly what goes where?

15
I have to mostly agree with you Josh, as of just now proxomitron is just slightly more powerful than admuncher but a hell of a lot more complicated to set up and maintain properly, admuncher (using the 4.7 beta version) does all I need just now and hopefully if Jeff gets the regexp filters into 4.8/9 and the per site filters while still keeping it just as easy to use then I'm sure glad I bought a copy when I did.

As you said free doesn't always mean better.

Pages: prev1 2 [3] 4 5 6 7 8 9next
Go to full version