Could someone help me with this code??

Hi!, I am really poor at Java, and was given this piece of code to fix. I have no idea why this compiles but does not run and have never dealt with packages either, so I would really appreciate it if someone could tell me what I could do to fix it!!
package Arrays;
import java.awt.*;
import java.awt.event.*;
*   This class demonstrates a simple application
*   A rather primitive ATM machine (needs work)
*   Quite similar to the CashRegister Applet
public class VirtualATM extends Frame implements ActionListener
     // the "screen"
     TextArea  display = new TextArea(8, 20);
     // some local variables
     private String current    = new String("");
     private double amount     = 0d;
     private double balance = 5000.0;
     private int opCode;
     // op code constants
     static final int PINENTRY   = 0;
     static final int DEPOSIT    = 1;
     static final int WITHDRAWAL = 2;
     // button labels - an array
     String [] btnLabels =
         "1", "2", "3", "Deposit",
         "4", "5", "6", "Withdraw",
         "7", "8", "9", "New Customer",
         "0", ".","Enter","Quit"
* Default constructor
public VirtualATM()
     super();
* Constructor with frame title
public VirtualATM(String title)
     super(title);
     setSize(400, 400);
     // inner class to detect window closing and make sure
     // quit method is executed before exit, not vital in
     // this case but a good habit to get into
     addWindowListener(new WindowAdapter()
          public void windowClosing(WindowEvent e)
               quit();
     // set up the display
     int nButtons = btnLabels.length;
     Panel keypad = new Panel();
     keypad.setLayout(new GridLayout(4, 4, 5, 5));
     Button[] keys = new Button[nButtons];
     for (int i = 0; i < nButtons; i++)
          keys[i] = new Button(btnLabels);
          keypad.add(keys[i]);
          keys[i].addActionListener(this);
          keys[i].setActionCommand(btnLabels[i]);
     setLayout(new GridLayout(2, 1, 10, 10));
     display.setEditable(false);
     add(display);
     add(keypad);
     setVisible(true);
     startup();
* Check the button presses
public void actionPerformed(ActionEvent e)
     String command = e.getActionCommand();
     char com = command.charAt(0);
     // see if the character is part of a number:
     if ((com >= '0') && (com <= '9') || (com == '.'))
          doNumber(com);
     else
          // check here for function buttons
          switch (com)
               case 'D' :
               current = "";
                    deposit();
                    break;
               case 'W' :
               current = "";
                    withdraw();
                    break;
               case 'N' :
                    startup();
                    break;
               case 'E' :
                    processOperation();
                    break;
               case 'Q' :
                    quit();
                    break;
* This method prompts for a deposit
public void deposit()
     opCode = DEPOSIT;
     display.append("\nPlease enter amount to deposit: ");
* This method processes number button presses
* Could add PIN validation
public void doNumber(char com)
     current += com;
     if (opCode == PINENTRY)
          display.append("*");
     else
          display.append("" + com);
* This method does the processing!
public void processOperation()
     amount = toDouble(current);
     switch (opCode)
          case PINENTRY :
               display.setText("Please choose a transaction");
               break;
          case DEPOSIT :
               if (amount > 0.0)
                    balance += amount;
                    display.setText("Thank you, your new balance is: " + balance);
               else
                    display.setText("You cannot deposit " + amount);
               break;
          case WITHDRAWAL :
               if (amount <= balance)
                    balance -= amount;
                    display.setText("Thank you, your new balance is: " + balance);
               else
                    display.setText("You cannot withdraw " + amount);
               break;
* This method quits
public void quit()
     System.exit(0);
* This method sets up for a new customer
public void startup()
     display.setText("Welcome to Virtual Banking with VOB\n\n");
     display.append("Please enter your PIN: ");
     amount = 0.0;
     current = "";
     balance = 5000.00;
     opCode = PINENTRY;
* converts a string to a double
private double toDouble(String s)
     double theValue = -1.0;
     try
          if (s != "")
               Double d = new Double(s);
               theValue = d.doubleValue();
     catch (NumberFormatException n)
          current = "";
     finally
          return theValue;
* This method prompts for a withdrawal
public void withdraw()
     opCode = WITHDRAWAL;
     display.append("\nPlease enter amount to withdraw: ");
class main{
     * Initialises the Application
     * Creation date: (07-Dec-00 23:10:49)
     public static void main(String[] args)
          VirtualATM myATM = new VirtualATM("Virtual Overseas Bank");

That sounds like a path or classpath issue issue. There are some instructions here for windows systems...
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html
Basically you want to set your path to where your java.exe file is.
You can probably run it like this though (if you are in the dir where your ATM class is and you put the path where your jdk is installed):
D:\jdk1.3\bin\java VirtualATM
Here is the code, changed (note that this forum tends to screw up the code a little):
package Arrays;
import java.awt.*;
import java.awt.event.*;
* This class demonstrates a simple application
* A rather primitive ATM machine (needs work)
* Quite similar to the CashRegister Applet
public class VirtualATM extends Frame implements ActionListener
// the "screen"
TextArea display = new TextArea(8, 20);
// some local variables
private String current = new String("");
private double amount = 0d;
private double balance = 5000.0;
private int opCode;
// op code constants
static final int PINENTRY = 0;
static final int DEPOSIT = 1;
static final int WITHDRAWAL = 2;
// button labels - an array
String [] btnLabels =
"1", "2", "3", "Deposit",
"4", "5", "6", "Withdraw",
"7", "8", "9", "New Customer",
"0", ".","Enter","Quit"
* Default constructor
public VirtualATM()
super();
* Constructor with frame title
public VirtualATM(String title)
super(title);
setSize(400, 400);
// inner class to detect window closing and make sure
// quit method is executed before exit, not vital in
// this case but a good habit to get into
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
quit();
// set up the display
int nButtons = btnLabels.length;
Panel keypad = new Panel();
keypad.setLayout(new GridLayout(4, 4, 5, 5));
Button[] keys = new Button[nButtons];
for (int i = 0; i < nButtons; i++)
keys[i] = new Button(btnLabels);
keypad.add(keys[i]);
keys[i].addActionListener(this);
keys[i].setActionCommand(btnLabels[i]);
setLayout(new GridLayout(2, 1, 10, 10));
display.setEditable(false);
add(display);
add(keypad);
setVisible(true);
startup();
* Check the button presses
public void actionPerformed(ActionEvent e)
String command = e.getActionCommand();
char com = command.charAt(0);
// see if the character is part of a number:
if ((com >= '0') && (com <= '9') || (com == '.'))
doNumber(com);
else
// check here for function buttons
switch (com)
case 'D' :
current = "";
deposit();
break;
case 'W' :
current = "";
withdraw();
break;
case 'N' :
startup();
break;
case 'E' :
processOperation();
break;
case 'Q' :
quit();
break;
* This method prompts for a deposit
public void deposit()
opCode = DEPOSIT;
display.append("\nPlease enter amount to deposit: ");
* This method processes number button presses
* Could add PIN validation
public void doNumber(char com)
current += com;
if (opCode == PINENTRY)
display.append("*");
else
display.append("" + com);
* This method does the processing!
public void processOperation()
amount = toDouble(current);
switch (opCode)
case PINENTRY :
display.setText("Please choose a transaction");
break;
case DEPOSIT :
if (amount > 0.0)
balance += amount;
display.setText("Thank you, your new balance is: " + balance);
else
display.setText("You cannot deposit " + amount);
break;
case WITHDRAWAL :
if (amount <= balance)
balance -= amount;
display.setText("Thank you, your new balance is: " + balance);
else
display.setText("You cannot withdraw " + amount);
break;
* This method quits
public void quit()
System.exit(0);
* This method sets up for a new customer
public void startup()
display.setText("Welcome to Virtual Banking with VOB\n\n");
display.append("Please enter your PIN: ");
amount = 0.0;
current = "";
balance = 5000.00;
opCode = PINENTRY;
* converts a string to a double
private double toDouble(String s)
double theValue = -1.0;
try
if (s != "")
Double d = new Double(s);
theValue = d.doubleValue();
catch (NumberFormatException n)
current = "";
finally
return theValue;
* This method prompts for a withdrawal
public void withdraw()
opCode = WITHDRAWAL;
display.append("\nPlease enter amount to withdraw: ");
* Initialises the Application
* Creation date: (07-Dec-00 23:10:49)
public static void main(String[] args)
VirtualATM myATM = new VirtualATM("Virtual Overseas Bank");

Similar Messages

  • TS2755 Whenever I send a message to another iPhone user via iMessage it is sending my Apple ID instead of my phone number.  Could someone help me with this??

    Whenever I send a message to another iPhone user via iMessage it is sending my Apple ID instead of my phone number. Could someone help me with this???

    Check this article: iOS: About Messages
    Additional Information
    You can change your iMessage Caller ID setting on iOS devices in Settings > Messages > Receive At > Caller ID. Note that the Caller ID setting is used only for new conversations. If you would like to change the address from which messages are sent, first change your Caller ID, and then delete the existing conversation and start a new one.
    iMessage responses will be sent from the address the recipient most recently messaged. For example, on iPhone you can receive messages sent to your Apple ID and phone number. A friend sends you a message to your Apple ID. Responses in this conversation will be sent from your Apple ID, even if your Caller ID is set to your phone number.

  • Yesterday for the first time i turned on my macpro 2011 model and i got a crazy gray screen with lines all over it ,so i held down the power button and turn off then restarted and all was ok could someone help me with this,what caused this shut down. werd

    yesterday for the first time i turned on my macpro 2011 model and i got a crazy gray screen with lines all over it ,so i held down the power button and turn off then restarted and all was ok could someone help me with this,what caused this shut down. werd

    Are the lines like psychedelic herringbone?  If yes, I had that happen once, it was something serious, like the
    Logic board. The good news is that it was fixed without any loss of data on the hard drive. Take it in to have Apple look at it ASAP.  I took it to TekServe at the time, they are very nice about preserving your data and user library when possible.
    Good luck and don't panic.

  • Can someone help me with this code?

    Hi all,
    I have a Flash component that links to a gallery, and I
    understand that I can create buttons to point to multiple
    galleries. (waiting too long for support from the suppliers)
    The User Guide says that I can use the following to create
    the connection:
    myThumbnailer2.loadGallery(24);
    That won't work, and it says that I need to include it in an
    onclipevent. I have no idea what i am doing and I was hoping
    someone could tell me what to script to get the text button I
    created to run this.
    Help would really be appreciated.
    Hugh

    Hi Hugh,
    You are right in that you can link to other galleries using
    the ID number (but, I assume, only TN2Admin (fCMSPro gallery
    document) defined galleries) with the code supplied.
    I think this may help - I'm a newbie with actionscript and I
    know nothing about Flashloaded so I may be way off beam here,
    but....
    First define a variable, this will be used in the 'show'
    (that's show, not load) gallery element of your code:
    var galNum: Number;
    Make as many buttons as required to launch a gallery (you say
    "each button opening one of several galleries" so I assume you want
    1 gallery per button) and give each an instance name.
    You then write the relevant code for each button function
    (assuming once more that the buttons are in the same frame) using
    the instance name (I use a separate layer in the frame to write
    actionscript and try not to attach code directly to objects - which
    then leads me to say yes you can put all the different buttons code
    in one frame)....
    myLoadGalBtn1.onRelease = function () {
    myThumbnailer2.loadGallery(24);
    galNum = 24;
    myLoadGalBtn2.onRelease = function () {
    myThumbnailer2.loadGallery(25);
    galNum = 25;
    notice the buttons have different instance names (the 1 &
    2 at the end - but you can call them what you like).
    Then you can use other code supplied to actually show the
    gallery (using the variable generated in each button click). Some
    code from Flashloaded will be along the lines of:
    myThumbnailer2.showGallery(25);
    so my guess is you can replace the actual number with the
    variable galNum inside the brackets to use the number generated by
    whatever button was pressed, like:
    myThumbnailer2.showGallery(galNum);
    Cheers
    Kol

  • Please someone help me with this code..

    hi, i have a big problem trying to figure out how to do this, i get this code somewhere in the net, so it's not me who code this, that's why i got this problem.
    this is a MIDlet games, something like gallaga. i like to add some features like the UP and DOWN movement and also i have a problem with his "fire", i can only shoot once after the fire image is gone in the screen, what i liked to have is even i pressed the fire button and press it again the fire will not gone, what i mean continues fire if i pressed everytime the fire button.
    i will post the code here so you can see it and give me some feedback. i need this badly, hoping to all you guys! thanks..for this forum.
    ----CODE BEGIN ---------------
    import java.io.IOException;
    import java.io.PrintStream;
    import java.util.Random;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    import javax.microedition.rms.RecordStore;
    import javax.microedition.rms.RecordStoreException;
    public class MobileGalaga extends MIDlet
    implements CommandListener, Runnable
    class ScoreScreen extends Canvas
    public void paint(Graphics g)
    g.setColor(0xffffff);
    g.fillRect(0, 0, MobileGalaga.WIDTH, MobileGalaga.HEIGHT);
    g.setColor(0x160291);
    g.setFont(MobileGalaga.fs);
    g.drawString("Help", MobileGalaga.CENTERW, 2, 17);
    g.setColor(0);
    g.drawString("Use left/right and fire", MobileGalaga.CENTERW, 20, 17);
    g.drawString("to destory the", MobileGalaga.CENTERW, 30, 17);
    g.drawString("incoming alien MobileGalaga", MobileGalaga.CENTERW, 40, 17);
    public void keyPressed(int i)
    int j = getGameAction(i);
    if(j == 8)
    display.setCurrent(titlescreen);
    ScoreScreen()
    class TitleScreen extends Canvas
    public void paint(Graphics g)
    g.setColor(0xffffff);
    g.fillRect(0, 0, MobileGalaga.WIDTH, MobileGalaga.HEIGHT);
    g.drawImage(MobileGalaga.logoimg, MobileGalaga.CENTERW, 15, 17);
    g.setColor(0);
    g.setFont(MobileGalaga.fs);
    g.drawString("Press 5 to", MobileGalaga.CENTERW, 43, 17);
    g.drawString("see help", MobileGalaga.CENTERW, 53, 17);
    public void keyPressed(int i)
    int j = getGameAction(i);
    if(j == 8)
    display.setCurrent(scorescreen);
    TitleScreen()
    class MainScreen extends Canvas
    public void paint(Graphics g)
    offg.setColor(0xffffff);
    offg.fillRect(0, 0, MobileGalaga.WIDTH, MobileGalaga.HEIGHT);
    for(int i = 0; i < MobileGalaga.slen; i++)
    if(!MobileGalaga.dead)
    offg.drawImage(MobileGalaga.alienimg[MobileGalaga.frame[i]], MobileGalaga.x[i], MobileGalaga.y[i], 17);
    if(!MobileGalaga.playerdead)
    offg.drawImage(MobileGalaga.playerimg, MobileGalaga.px, MobileGalaga.py, 17);
    } else
    if(MobileGalaga.explodeframe < 3)
    offg.drawImage(MobileGalaga.explosionimg[MobileGalaga.explodeframe], MobileGalaga.px, MobileGalaga.py, 17);
    MobileGalaga.explodeframe++;
    if(!MobileGalaga.gameover)
    MobileGalaga.playerpause++;
    if(MobileGalaga.playerpause < 50)
    MobileGalaga.playerpause++;
    } else
    MobileGalaga.playerdead = false;
    MobileGalaga.playerpause = 0;
    MobileGalaga.px = MobileGalaga.CENTERW;
    offg.setColor(0);
    offg.drawString(MobileGalaga.scorestr, MobileGalaga.WIDTH, 0, 24);
    offg.drawImage(MobileGalaga.playerimg, 0, 0, 20);
    offg.drawString(MobileGalaga.lives + "", 12, 0, 20);
    if(MobileGalaga.laser)
    offg.drawLine(MobileGalaga.laserx, MobileGalaga.lasery, MobileGalaga.laserx, MobileGalaga.lasery + 4);
    if(MobileGalaga.showscores)
    for(int j = 0; j < 5; j++)
    if(j == MobileGalaga.rank)
    offg.setColor(0xff0000);
    else
    offg.setColor(0);
    offg.drawString((j + 1) + " .... " + getScoreStr(MobileGalaga.highscore[j]), MobileGalaga.CENTERW, 20 + j * 10, 17);
    if(MobileGalaga.showmessage)
    offg.setColor(0xff0000);
    offg.drawString(MobileGalaga.msg, MobileGalaga.CENTERW, MobileGalaga.CENTERH, 17);
    MobileGalaga.messagepause++;
    if(MobileGalaga.messagepause > 20)
    MobileGalaga.showmessage = false;
    MobileGalaga.messagepause = 0;
    if(MobileGalaga.gameover)
    MobileGalaga.showscores = true;
    else
    if(MobileGalaga.wavecomplete)
    initWave();
    g.drawImage(offimg, 0, 0, 20);
    public void keyPressed(int i)
    int j = getGameAction(i);
    if(j == 2)
    MobileGalaga.playerLeft = true;
    else
    if(j == 5)
    MobileGalaga.playerRight = true;
    else
    if(j == 8)
    fireLaser();
    public void keyReleased(int i)
    int j = getGameAction(i);
    if(j == 2)
    MobileGalaga.playerLeft = false;
    else
    if(j == 5)
    MobileGalaga.playerRight = false;
    private Image offimg;
    private Graphics offg;
    public MainScreen()
    offimg = Image.createImage(getWidth(), getHeight());
    offg = offimg.getGraphics();
    offg.setFont(MobileGalaga.fs);
    public MobileGalaga()
    rand = new Random();
    display = Display.getDisplay(this);
    mainscreen = new MainScreen();
    titlescreen = new TitleScreen();
    scorescreen = new ScoreScreen();
    WIDTH = mainscreen.getWidth();
    HEIGHT = mainscreen.getHeight();
    CENTERW = WIDTH / 2;
    CENTERH = HEIGHT / 2;
    exitCommand = new Command("Exit", 7, 1);
    playCommand = new Command("Play", 1, 1);
    quitCommand = new Command("Quit", 1, 1);
    againCommand = new Command("Again", 1, 1);
    nullCommand = new Command("", 1, 1);
    try
    alienimg[0] = Image.createImage("/alien1.png");
    alienimg[1] = Image.createImage("/alien2.png");
    explosionimg[0] = Image.createImage("/explosion1.png");
    explosionimg[1] = Image.createImage("/explosion2.png");
    explosionimg[2] = Image.createImage("/explosion3.png");
    playerimg = Image.createImage("/player.png");
    logoimg = Image.createImage("/logo.png");
    catch(IOException ioexception)
    db("Couldn't get images!");
    imgW = alienimg[0].getWidth();
    imgH = alienimg[0].getHeight();
    edgeH = imgW / 2;
    edgeV = imgH / 2;
    pimgW = playerimg.getWidth();
    pimgH = playerimg.getHeight();
    pedgeH = pimgW / 2;
    pedgeV = pimgH / 2;
    highscore = getHighScores();
    public void run()
    while(runner)
    rp();
    updatePos();
    try
    MobileGalaga _tmp = this;
    Thread.sleep(75L);
    catch(InterruptedException interruptedexception)
    db("interrupted");
    runner = false;
    MobileGalaga _tmp1 = this;
    Thread.yield();
    public void startApp()
    throws MIDletStateChangeException
    display.setCurrent(titlescreen);
    addBeginCommands(titlescreen, false);
    addBeginCommands(scorescreen, false);
    addPlayCommands(mainscreen, false);
    public void pauseApp()
    public void destroyApp(boolean flag)
    runner = false;
    th = null;
    private void rp()
    mainscreen.repaint();
    private void startGame()
    initGame();
    if(th == null)
    th = new Thread(this);
    runner = true;
    th.start();
    private void initGame()
    px = CENTERW;
    py = HEIGHT - pedgeV - pimgH;
    packcount = 0;
    lives = 3;
    score = 0;
    scorestr = "000000";
    rank = -1;
    difficulty = 400;
    wave = 1;
    initWave();
    private void initWave()
    for(int i = 0; i < slen; i++)
    frame[i] = i % 2;
    x[i] = packX[i] = sposX[i];
    y[i] = packY[i] = sposY[i];
    dx[i] = packdx = alien_dx_right;
    dy[i] = packdy = alien_dy_right;
    dxcount[i] = dycount[i] = 0;
    pmode[i] = 0;
    flying[i] = false;
    dead[i] = false;
    playerLeft = false;
    playerRight = false;
    laser = false;
    playerdead = false;
    showscores = false;
    showmessage = false;
    gameover = false;
    wavecomplete = false;
    playerpause = 0;
    messagepause = 0;
    killed = 0;
    private void updatePos()
    if(playerLeft)
    updatePlayerPos(-2);
    else
    if(playerRight)
    updatePlayerPos(2);
    fly = Math.abs(rand.nextInt() % difficulty);
    if(fly < slen && !flying[fly] && !dead[fly])
    if(x[fly] < CENTERW)
    setDX(fly, alien_dx_flyright, 2);
    setDY(fly, alien_dy_flyright, 2);
    } else
    setDX(fly, alien_dx_flyleft, 2);
    setDY(fly, alien_dy_flyleft, 2);
    flying[fly] = true;
    for(int i = 0; i < slen; i++)
    if(!dead[i])
    if(!flying[i])
    if(x[i] + edgeH + dx[i][dxcount[i]] > WIDTH)
    changePackDir(alien_dx_left, alien_dy_left);
    if((x[i] - edgeH) + dx[i][dxcount[i]] < 0)
    changePackDir(alien_dx_right, alien_dy_right);
    } else
    if(y[i] + edgeV + dy[i][dycount[i]] > HEIGHT)
    x[i] = packX[i];
    y[i] = packY[i];
    flying[i] = false;
    setDX(i, packdx, 0);
    setDY(i, packdy, 0);
    if(!playerdead && y[i] <= py + pedgeV && y[i] >= py - pedgeV && x[i] <= px + pedgeH && x[i] >= px - pedgeH)
    playerHit();
    if(laser && lasery <= y[i] + edgeV && lasery >= y[i] - edgeV && laserx <= x[i] + edgeH && laserx >= x[i] - edgeH)
    alienHit(i);
    for(int j = 0; j < slen; j++)
    if(!dead[j])
    if(framecount == 3)
    frame[j] = frame[j] + 1 < 2 ? 1 : 0;
    lastx = x[j];
    lasty = y[j];
    x[j] += dx[j][dxcount[j]];
    y[j] += dy[j][dycount[j]];
    if(pmode[j] == 0)
    dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : 0;
    dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : 0;
    } else
    if(pmode[j] == 2)
    dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : dxcount[j];
    dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : dycount[j];
    packX[j] += packdx[packcount];
    packY[j] += packdy[packcount];
    packcount = packcount + 1 < packlen ? packcount + 1 : 0;
    framecount = framecount + 1 < 4 ? framecount + 1 : 0;
    if(laser)
    lasery -= 6;
    if(lasery < 0)
    laser = false;
    private void setDX(int i, int ai[], int j)
    if(i == -1)
    for(int k = 0; k < slen; k++)
    if(!flying[k])
    dx[k] = ai;
    dxcount[k] = 0;
    pmode[k] = j;
    } else
    dx[i] = ai;
    dxcount[i] = 0;
    pmode[i] = j;
    private void setDY(int i, int ai[], int j)
    if(i == -1)
    for(int k = 0; k < slen; k++)
    if(!flying[k])
    dy[k] = ai;
    dycount[k] = 0;
    pmode[k] = j;
    } else
    dy[i] = ai;
    dycount[i] = 0;
    pmode[i] = j;
    private void changePackDir(int ai[], int ai1[])
    setDX(-1, ai, 0);
    setDY(-1, ai1, 0);
    packdx = ai;
    packdy = ai1;
    packcount = 0;
    private void updatePlayerPos(int i)
    plastx = px;
    px += i;
    if(px + pedgeH > WIDTH || px - pedgeH < 0)
    px = plastx;
    private void fireLaser()
    if(!laser)
    laser = true;
    laserx = px;
    lasery = py;
    private void alienHit(int i)
    if(!playerdead)
    dead[i] = true;
    laser = false;
    killed++;
    if(flying[i])
    score += 200;
    else
    score += 50;
    if(killed == slen)
    waveComplete();
    scorestr = getScoreStr(score);
    private void playerHit()
    playerdead = true;
    playerpause = 0;
    explodeframe = 0;
    lives--;
    if(lives == 0)
    gameOver();
    private void waveComplete()
    wavecomplete = true;
    difficulty -= 100;
    if(difficulty < 100)
    difficulty = 100;
    msg = "WAVE " + wave + " COMPLETE";
    messagepause = 0;
    showmessage = true;
    wave++;
    score += 1000 * wave;
    scorestr = getScoreStr(score);
    private void gameOver()
    gameover = true;
    msg = "GAME OVER";
    for(int i = 0; i < 5; i++)
    if(score < highscore[i])
    continue;
    for(int j = 4; j > i; j--)
    highscore[j] = highscore[j - 1];
    highscore[i] = score;
    rank = i;
    break;
    setHighScores();
    showmessage = true;
    messagepause = 0;
    addEndCommands(mainscreen, true);
    private void addBeginCommands(Displayable displayable, boolean flag)
    if(flag)
    removeCommands();
    displayable.addCommand(playCommand);
    displayable.addCommand(exitCommand);
    displayable.setCommandListener(this);
    private void addPlayCommands(Displayable displayable, boolean flag)
    if(flag)
    removeCommands();
    displayable.addCommand(nullCommand);
    displayable.addCommand(quitCommand);
    displayable.setCommandListener(this);
    private void addEndCommands(Displayable displayable, boolean flag)
    if(flag)
    removeCommands();
    displayable.addCommand(againCommand);
    displayable.addCommand(quitCommand);
    displayable.setCommandListener(this);
    private void removeCommands()
    Displayable displayable = display.getCurrent();
    displayable.removeCommand(nullCommand);
    displayable.removeCommand(quitCommand);
    displayable.removeCommand(againCommand);
    displayable.removeCommand(playCommand);
    displayable.removeCommand(exitCommand);
    public void commandAction(Command command, Displayable displayable)
    if(command == playCommand)
    display.setCurrent(mainscreen);
    startGame();
    if(command == quitCommand)
    runner = false;
    while(th.isAlive()) ;
    th = null;
    addPlayCommands(mainscreen, true);
    display.setCurrent(titlescreen);
    if(command == againCommand)
    runner = false;
    while(th.isAlive()) ;
    th = null;
    display.setCurrent(mainscreen);
    addPlayCommands(mainscreen, true);
    startGame();
    if(command == exitCommand)
    destroyApp(false);
    notifyDestroyed();
    private int[] getHighScores()
    int ai[] = new int[5];
    ai[0] = 5000;
    ai[1] = 4000;
    ai[2] = 3000;
    ai[3] = 2000;
    ai[4] = 1000;
    byte abyte0[][] = new byte[5][6];
    try
    hsdata = RecordStore.openRecordStore("MobileGalaga", true);
    int i = hsdata.getNumRecords();
    if(i == 0)
    for(int j = 0; j < 5; j++)
    abyte0[j] = Integer.toString(ai[j]).getBytes();
    hsdata.addRecord(abyte0[j], 0, abyte0[j].length);
    } else
    for(int k = 0; k < 5; k++)
    abyte0[k] = hsdata.getRecord(k + 1);
    String s = "";
    for(int l = 0; l < abyte0[k].length; l++)
    s = s + (char)abyte0[k][l] + "";
    ai[k] = Integer.parseInt(s);
    catch(RecordStoreException recordstoreexception)
    db("problem with initialising highscore data\n" + recordstoreexception);
    return ai;
    private void setHighScores()
    byte abyte0[][] = new byte[5][6];
    try
    hsdata = RecordStore.openRecordStore("MobileGalaga", true);
    for(int i = 0; i < 5; i++)
    abyte0[i] = Integer.toString(highscore[i]).getBytes();
    hsdata.setRecord(i + 1, abyte0[i], 0, abyte0[i].length);
    catch(RecordStoreException recordstoreexception)
    db("problem with setting highscore data\n" + recordstoreexception);
    private String getScoreStr(int i)
    templen = 6 - (i + "").length();
    tempstr = "";
    for(int j = 0; j < templen; j++)
    tempstr = tempstr + "0";
    return tempstr + i;
    public static void db(String s)
    System.out.println(s);
    public static void db(int i)
    System.out.println(i + "");
    private Display display;
    private Command exitCommand;
    private Command playCommand;
    private Command quitCommand;
    private Command againCommand;
    private Command nullCommand;
    private MainScreen mainscreen;
    private TitleScreen titlescreen;
    private ScoreScreen scorescreen;
    private static int WIDTH;
    private static int HEIGHT;
    private static int CENTERW;
    private static int CENTERH;
    private boolean runner;
    private Thread th;
    private Random rand;
    private static final int RED = 0xff0000;
    private static final int ORANGE = 0xff9100;
    private static final int YELLOW = 0xffff00;
    private static final int WHITE = 0xffffff;
    private static final int BLACK = 0;
    private static final int BLUE = 0x160291;
    private static Image alienimg[] = new Image[2];
    private static Image explosionimg[] = new Image[3];
    private static Image playerimg;
    private static Image logoimg;
    private static int imgH;
    private static int imgW;
    private static int pimgH;
    private static int pimgW;
    private static int edgeH;
    private static int edgeV;
    private static int pedgeH;
    private static int pedgeV;
    private static final Font fs = Font.getFont(64, 0, 8);
    private static final Font fl = Font.getFont(64, 1, 16);
    private static final int sposX[] = {
    16, 28, 40, 52, 4, 16, 28, 40, 52, 64,
    4, 16, 28, 40, 52, 64
    private static final int sposY[] = {
    14, 14, 14, 14, 26, 26, 26, 26, 26, 26,
    38, 38, 38, 38, 38, 38
    private static final int LOOP = 0;
    private static final int ONCE = 1;
    private static final int HOLD = 2;
    private static final int move_none[] = {
    0
    private static final int alien_dx_right[] = {
    1, 1, 1, 1, 1, 1, 1, 1
    private static final int alien_dy_right[] = {
    0, 0, 1, 1, 0, 0, -1, -1
    private static final int alien_dx_left[] = {
    -1, -1, -1, -1, -1, -1, -1, -1
    private static final int alien_dy_left[] = {
    0, 0, -1, -1, 0, 0, 1, 1
    private static final int alien_dx_flyright[] = {
    1, 1, 1, 0, -1, -1, -1, -1, -1, 0,
    1, 1, 2, 3, 4, 5, 6
    private static final int alien_dy_flyright[] = {
    0, -1, -1, -1, -1, -1, 0, 1, 1, 1,
    1, 1, 2, 3, 4, 5, 6
    private static final int alien_dx_flyleft[] = {
    -1, -1, -1, 0, 1, 1, 1, 1, 1, 0,
    -1, -1, -2, -3, -4, -5, -6
    private static final int alien_dy_flyleft[] = {
    0, -1, -1, -1, -1, -1, 0, 1, 1, 1,
    1, 1, 2, 3, 4, 5, 6
    private static final int slen;
    private static final int ailen;
    private static final int packlen;
    private static int pmode[];
    private static int x[];
    private static int y[];
    private static int dx[][];
    private static int dy[][];
    private static int dxcount[];
    private static int dycount[];
    private static int frame[];
    private static boolean flying[];
    private static boolean dead[];
    private static boolean exploding[];
    private static int lastx;
    private static int lasty;
    private static int fly;
    private static int packX[];
    private static int packY[];
    private static int packdx[];
    private static int packdy[];
    private static int packcount;
    private static int framecount = 3;
    private static int px;
    private static int py;
    private static int plastx;
    private static int score;
    private static String scorestr;
    private static int lives;
    private static int killed;
    private static boolean playerdead;
    private static int explodeframe;
    private static int playerpause;
    private static int rank;
    private static boolean playerLeft;
    private static boolean playerRight;
    private static boolean laser;
    private static int laserx;
    private static int lasery;
    private static RecordStore hsdata;
    private static int highscore[] = new int[5];
    private static boolean showmessage;
    private static boolean showscores;
    private static boolean gameover;
    private static boolean wavecomplete;
    private static int messagepause;
    private static String msg;
    private static int difficulty;
    private static int wave;
    private static String tempstr;
    private static int templen;
    static
    slen = sposX.length;
    ailen = alien_dx_flyright.length;
    packlen = alien_dx_right.length;
    pmode = new int[slen];
    x = new int[slen];
    y = new int[slen];
    dx = new int[slen][ailen];
    dy = new int[slen][ailen];
    dxcount = new int[slen];
    dycount = new int[slen];
    frame = new int[slen];
    flying = new boolean[slen];
    dead = new boolean[slen];
    exploding = new boolean[slen];
    packX = new int[slen];
    packY = new int[slen];
    packdx = new int[packlen];
    packdy = new int[packlen];
    ----END OF CODE ----------------

    hi sorry if it's too big! i hope i can explain this very well (you know i only got this code in the net), if you try to run the program in emulator, the and lunch it will it will first display the title screen and if you hit the pressed key 5 it will display help,
    so my problem is how to move UP and DOWN and also if i pressed the fire button it will continue to fire. here is the code.
    //Code for the Left,Right,UP and Down movement and also the fire
    public void keyPressed(int i)
    int j = getGameAction(i);
    if(j == 2)
    MobileGalaga.playerLeft = true; //this is ok
    else
    if(j == 5)
    MobileGalaga.playerRight = true; //this is ok
    else
    if(j==1)
    MobileGalaga.playerUp = true; //i add this only, this has a problem
    else
    if(j==6)
    MobileGalaga.playerDown = true; //i add this only, this has a problem
    else
    if(j == 8)
    fireLaser(); //for the release of fire
    //for the release of key pressed
    public void keyReleased(int i)
    int j = getGameAction(i);
    if(j == 2)
    MobileGalaga.playerLeft = false;
    else
    if(j == 5)
    MobileGalaga.playerRight = false;
    //Update the position base on key pressed
    private void updatePos()
    if(playerLeft)
    updatePlayerPos(-5);
    else
    if(playerUp)
    updatePlayerPos1(-4);
    else
    if(playerDown)
    updatePlayerPos1(4);
    else
    if(playerRight)
    updatePlayerPos(5);
    fly = Math.abs(rand.nextInt() % difficulty);
    if(fly < slen && !flying[fly] && !dead[fly])
    if(x[fly] < CENTERW)
    setDX(fly, alien_dx_flyright, 2);
    setDY(fly, alien_dy_flyright, 2);
    } else
    setDX(fly, alien_dx_flyleft, 2);
    setDY(fly, alien_dy_flyleft, 2);
    flying[fly] = true;
    for(int i = 0; i < slen; i++)
    if(!dead)
    if(!flying[i])
    if(x[i] + edgeH + dx[i][dxcount[i]] > WIDTH)
    changePackDir(alien_dx_left, alien_dy_left);
    if((x[i] - edgeH) + dx[i][dxcount[i]] < 0)
    changePackDir(alien_dx_right, alien_dy_right);
    } else
    if(y[i] + edgeV + dy[i][dycount[i]] > HEIGHT)
    x[i] = packX[i];
    y[i] = packY[i];
    flying[i] = false;
    setDX(i, packdx, 0);
    setDY(i, packdy, 0);
    if(!playerdead && y[i] <= py + pedgeV && y[i] >= py - pedgeV && x[i] <= px + pedgeH && x[i] >= px - pedgeH)
    playerHit();
    if(laser && lasery <= y[i] + edgeV && lasery >= y[i] - edgeV && laserx <= x[i] + edgeH && laserx >= x[i] - edgeH)
    alienHit(i);
    for(int j = 0; j < slen; j++)
    if(!dead[j])
    if(framecount == 3)
    frame[j] = frame[j] + 1 < 2 ? 1 : 0;
    lastx = x[j];
    lasty = y[j];
    x[j] += dx[j][dxcount[j]];
    y[j] += dy[j][dycount[j]];
    if(pmode[j] == 0)
    dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : 0;
    dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : 0;
    } else
    if(pmode[j] == 2)
    dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : dxcount[j];
    dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : dycount[j];
    packX[j] += packdx[packcount];
    packY[j] += packdy[packcount];
    packcount = packcount + 1 < packlen ? packcount + 1 : 0;
    framecount = framecount + 1 < 4 ? framecount + 1 : 0;
    if(laser)
    lasery -= 6;
    if(lasery < 0 )
    laser = false;
    // this will move the object UP,DOWN,Left and Right
    private void updatePlayerPos(int i)
    plastx = px;
    px += i;
    if(px + pedgeH > WIDTH || px - pedgeH < 0)
    px = plastx;
    private void updatePlayerPos1(int i)
    plastx = py;
    py += i;
    if(px + pedgeV > HEIGHT || px - pedgeV < 0)
    px = plastx;
    // This will fire, if you hit the fire button
    private void fireLaser()
    if(!laser)
    laser = true;
    laserx = px;
    lasery = py;
    sorry if it's too long i just want too explain this. if anyone like to see this and run so that you can see it also, i can send an email.
    thanks,
    alek

  • Could someone help me with this error: java.sql.SQLException: Closed Connec

    My code:
    <%@ include file="../setupcache.jsp"%>
    <%
    if(connectionPool_dig==null){
    %>
    <p>Could not connect to database. Please try again, thank!</p>
    <%          
         return ;
    Connection con = connectionPool_dig.getConnection();
    if(con==null){
    %>
    <p>Could not connect to database. Please try again, thank!</p>
    <%          
         return;
         String file = request.getParameter("m_FILE");
              file = "a";
         String sql = " SELECT *"+
              " FROM "+
              " FILEUPLOAD, SUBJECT"+
              " WHERE "+
              " FILEUPLOAD.SUBJECTCODE = SUBJECT.CODE AND UPPER(FILEUPLOAD.FILENAME) LIKE(UPPER(?))";
         PreparedStatement stmt = con.prepareStatement(sql);
         stmt.setString(1,"%"+file+"%");
         ResultSet rs = stmt.executeQuery();
         while(rs.next()){
              out.println("<br>"+rs.getString(1));
              out.println("<br>"+rs.getString(2));
              out.println("<br>"+rs.getString(3));
              out.println("<br>"+rs.getString(4));
         rs.close();
         stmt.close();
    try{
         con.close();
    }catch(SQLException e){}
    %>
    it usualy generate that error (once wrong then right then wrong....), but if I don't close connection (con.close), it work well. Could some one help me!

    Hi,
    I think that it should be better that returning the Connection
    instance back to the Connection Pool. The connection
    should not be close by you. it should controlled by the
    connection pool mechanism. So I think that you should
    check out your connection pool usage document for the
    right usage.
    If your code is the case, the connection in connection
    pool will get less and your connection pool mechanism
    may need to reallocate a new one for application. I
    don't think that it is right.
    good luck,
    Alfred Wu

  • Hi could someone help me with this basic issue ..

    'sql*plus' is not recognized as an internal or external command,
    operable program or batch file.
    I have installed expression addition for practice on a win xp OS it was working fine but now this is the error when , I am trying to start the data base.
    checked the environmental variables they seem to be ok but still no progress .
    Thanks,
    Max

    Hi,
    In hurry are you typing sql*plus instead of sqlplus?
    you could go to <oracle-home>/bin directory and run  (ex: C:\oraclexe\app\oracle\product\11.2.0\server\bin\sqlplus.exe)
    Regards
    Yoonas

  • I would like to change the owners name on my ipad2 to my daughters name and credit. Could someone help me figure this out?

    I would like to change the owners name on my ipad2 to my daughters name and credit. Could someone help me figure this out?

    Sign out from Find My Phone in iCloud, and sign out from your Apple ID in Settings/iTunes & App Store
    Then setup as a new phone with iTunes and when your Daughter sets it up for the first time she can add or set up her own Apple ID.
    Cheers
    Pete

  • Could someone help me with instructions for doing a clean install for iMac with mountain lion 10.8.4 ?

       Could someone help me with instructions for doing a clean install for Could someone help me with instructions for doing a clean install for an early 2009 iMac 20"  with Mountain Lion 10.8.4 ?
       Thank You,
                                leetruitt

       Barney,  William,  nbar, Galt\'s Gulch:
       A nephew stayed with us to take a course at the local community college last semester. I allowed him use of my mac for research just after I installed Mountain Lion. He decided to "help out" and ran a 3rd party clean and tune up app., Magician.  The tune up wiped over 1200 titles of my music in iTunes,  also a path of folders with names containing nothing but more empty folders with names. Almost every program I open and run for a short time crashes, also folders and programs are in wrong places, or cannot be located (the nephew, for instance). Up to this time I have always been able to track a problem far enough to resolve it by careful persistence and good luck, but I do not have the tech savvy to solve this one without getting in deeper. I have run disk utility saveral times and always get  variations of this:
    ACL found but not expected on
    "private/etc/resolve.conf"
    "private/etc/raddb/sites-enabled/inner-tunnel"
    "private/etc/rabbd/sites-enabled/control-socket"
         Also, after four years of intense daily use it is cluttered with much junk,  and every app that I was curious about, and I am a very curious guy.
       So I know my limits, (and now my nephew). I dumped my pc for a Strawberry iMac a few years ago, and so far every problem I've encountered, or brought on myself, the Mac has resolved with its own inner elegance - in spite of my novice bungels - and now I honestly feel ashamed, in addition to the need to apologize to a machine for allowing a peasant into the Royal Grounds - so I am calling the Wise Ones in for this one.
       Crazy, I know, but to me a Mac represents something far beyond the ordinary  input ➛ process  ➛ output  title/function customarily assigned to a machine - I sense an odd kind of morality involved, one that I need to respect.
        So, these are my reasons for wanting to do a clean install, correctly.
            Thank you,  Truitt

  • Could someone help me with comparing the contents of 2 folders?

    I'm trying to compare my iTunes music folder which is located in it's default location with a external USB hard drive. I was reading this article on how to do it using Terminal but I have NO CLUE on what to type in the command line. I'm clueless on this! Could someone help me with the commands I need to compare the 2 folders? I've included the link about what I'm trying to accomplish.
    http://www.macworld.com/article/132219/2008/02/termfoldercomp.html

    I tell you how. But remember that Terminal isn't a good place to be kicking around if you're not sure of what your doing. You can issue many commands as root that are irreversible. Tread very carefully, or get yourself a good GUI utility that can do that.
    It's asking you to cd (change directory to the folder that your files for comparison are in.
    So, you type, cd (leave a space) then you can just drag the folder to the Terminal and it will fill in the rest of the path.
    Then press Return
    Then type this at the prompt:
    diff -rq folder1 folder2
    (replacing "folder1 folder2 with the name of your folders. Leave spaces where indicated.
    Press return.
    -mj

  • Can somebody help me with this code?

    Can anyone help me with this code? My problem is that i can't
    seem to position this form, i want to be able to center it
    vertically & horizontally in a div either using CSS or any
    other means.
    <div id="searchbar"><!--Search Bar -->
    <div id="searchcart">
    <div class="serchcartcont">
    <form action='
    http://www.romancart.com/search.asp'
    name="engine" target=searchwin id="engine">
    <input type=hidden value=????? name=storeid>
    <input type=text value='' name=searchterm>
    <input type=submit value='Go'> </form>
    </div>
    </div>
    <div class="searchcont">Search For
    Products:</div>
    </div><!-- End Search Bar -->
    Pleasssssseeeeeeee Help
    Thanks

    Hi,
    Your form is defined in a div named "serchcartcont", you can
    use attributes like position and align of the div to do what you
    want to do. But there are two more dives above this dive, you will
    have define the height width of these before you can center align
    the inner most div. If you are not defining the height & width
    then by default it decide it automatically to just fit the content
    in it.
    Hope this helps.
    Maneet
    LeXolution IT Services
    Web Development
    Company

  • I have iOS 7. When I go to the itunes store on my ipod touch it gives me a blank screen with nothing on it. I restarted my ipod touch and it didn't work. Can someone help me with this?

    I have iOS 7. When I go to the itunes store on my ipod touch it gives me a blank screen with nothing on it. I restarted my ipod touch and it didn't work. Can someone help me with this?

    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Go to Settings>iTunes and App stores and sign out and sign back in
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                                                                
    - Restore to factory settings/new iOS device.      

  • The calender on my iPhone 4 with iOS 6 no longer syncs with iCal 4.0.4 on my mac OS 10.6.8. However it is syncing with my iCloud account. Can someone help me with this?

    The calender on my iPhone 4 with iOS 6 no longer syncs with iCal 4.0.4 on my mac OS 10.6.8. However it is syncing with my iCloud account. Can someone help me with this?

    FYI: It seems it was a network problem with my WinXP PC. After complete deletion and new installation of XP and iTunes my iPhone will be recognized correctly, Wifi synchronization works (mostly) fine.

  • I have a problem with my blackberry 9360, I bought it last 2months, and now when I use video camera or camera I saw a red and blue line. Can someone help me with this issue?

    I have a problem with my blackberry 9360, I bought it last 2months, and now when I use video camera or camera I saw a red and blue line. Can someone help me with this issue?

    Hello zukafu, 
    Welcome to the forums. 
    In this case we can try to reload the software on the BlackBerry® smartphone to make sure it is running the latest version and there are no issues with the OS.
    Here is how to backup your BlackBerry smartphone http://bbry.lv/oPVWXc
    Once you have backed up your BlackBerry smartphone please follow the link below to complete a clean reload of the BlackBerry smartphone software.
    Link: http://www.blackberry.com/btsc/KB03621
    Once completed test it and proceed with a selective restore, here is how to restore http://bbry.lv/qgQxLo
    Thank you
    -SR
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • HT5655 I followed all the instructions to update Flash Player, but the installation fails at around 90%, it says that there is an Application running (Safari) bit I actually close all Apps. already. can someone help me with this issue ?? Thanks

    I have followed the instructions to update Flash Player, the Installation Fails at about 90%, it says that there is an Application running (Safari) and it says to close all the apps. and start again ... but I already close all the Applications ... none is running ... can someone help me with this issue ??? Thanks ...

    Dear Dominic
    Brilliant reply. Simple English. Simple to follow instructions. And it worked immediately, first time.
    Why couldn't the Apple and Adobe corporations get their programming right first time? We spend billions of UK pounds and US dollars with them. They reply with incompetent programming such as this, and arrogance to their customers in issuing faulty systems without doing the most rudimentary checks.
    Anyway, I certainly shan't be buying another Apple as this is the most unreliable, most incomprehensible, most illogical and downright thoughtless shoddy piece of computer kit which I have ever owned. And all of it is rubbish ~ emails disappear, photos can't be organised properly, spreadsheets don't work, Pages is laborious… the list goes on and on...
    But thanks to you Dominic, I have been able to load Adoble Flashj… maybe eyou should get  a job at Apple, and set them all on the right course to how to work simply and correctly with customers.
    Thanks again,
    David

Maybe you are looking for

  • MDB (2-phase commit) behavior during abnormal JMS termination

    Hello to everyone! I plan to test the following scenario tomorrow (sort of a bug replication in our system). Anyway, wanted to know in advance the expected behavior (just in case one of you already know or have an experience related to this test). Th

  • Foreign trade header data in billing doc.

    Hi gurus, while trying to save billing doc (F8,F2), the document is getting saved but gives a message as Forigein Trade data incomplete, Now This can be overcome by adding the required details in the billing document header and then saving. But in do

  • Difference Between Oracle Database 10g And Oracle 10g Express Edition

    Can any body Tell me What is The Difference Between Oracle Database 10g And Oracle 10g Express Edition.

  • Saving messages in Outlook

    I am using Microsoft Outlook for Mac 20111 and have been able to save emails by clicking FILE and SAVE AS.. Now I do not get the option to 'SAVE AS..' only 'SAVE'. I want to save the emails as a file but can no longer do it. Any ideas what has change

  • Screen redraw prob CS3-sometimes crash

    Nothing open but Bridge and Photoshop-CS3 If I open more than two large files (30-40mb in size) and I try to drag the images around the screen, it will hang or not finish redrawing the image in it's new location. Sometimes it will crash PS. XP Pro-Du