Trouble updating variables

Hi guys,
This is proabably a really easy answer that i'm missing, but I've been staring at this code for several hours now, and am not making much progress. It is suppossed to be a simple game of craps. I am having trouble getting the variable amount to update. Here are the bits of the code dealing with amount. Please let me know if you need anything else.
Also, I know the code is really messy, I just started learning java, and am still trying to wrap my head around the basics. Any suggestions you have would be appreciated.
public void begin(String name, int amount, final int GOAL){//start begin method
     getBet(amount); //calls the method to get the player's bet
     playGame(bet, amount);
     dispMessage(win, bet, amount, name);
     System.exit(1);
} // end begin method
public void getBet(int amount){//start getBet
    JOptionPane.showMessageDialog(null,"You currently have "+amount+
    " dollars.  Your goal is 300 dollars.", "Current Money", JOptionPane.INFORMATION_MESSAGE);//tells player current amount of money and the goal they are trying to reach
          String input = JOptionPane.showInputDialog (null,        //prompts for the amount of the bet
       "Please enter the amound you wish to bet",
       "Place Bet", JOptionPane.QUESTION_MESSAGE);
        bet = Integer.parseInt(input);
     if(bet>amount) //error checks the bet amount
     JOptionPane.showMessageDialog(null, "You do not have enough money to place that bet. Please enter another amount.",
     "Error Message", JOptionPane.ERROR_MESSAGE);
     getBet(amount);
else
     return;     
     }//end method getBet
private void dispMessage(boolean win, int bet, int amount, String name) {
     if (win == true){          
         winBet(bet, amount);
          JOptionPane.showMessageDialog(null, ""+name+" you won "+bet+
          " dollars. You now have "+(amount)+ " dollars.   To play again, press enter", "Winner", JOptionPane.INFORMATION_MESSAGE);
          playGame(bet, amount);
     else
          if((win == false)&&(amount>=0)){
         loseBet(bet, amount);
          JOptionPane.showMessageDialog(null, "You lost the game. You now have "+amount+
          ". To play again, press enter.", "Loser", JOptionPane.INFORMATION_MESSAGE);
          playGame(bet, amount);
     else
     JOptionPane.showMessageDialog(null, "You are out of money", "Loser", JOptionPane.INFORMATION_MESSAGE);
     playGame(bet, amount);
     }//end dispMessage method
     public int winBet(int bet, int amount){//start winBet method
               amount = amount +bet;
               return amount;
               }//end winBet method
     public int loseBet(int bet, int amount){//start loseBet method
               amount = amount-bet;
               return amount;
                    }//end loseBet method
     class DicePlayer{// DicePlayer class
    String name = JOptionPane.showInputDialog (null,//prompts for the amount of the bet
       "Please enter your name",
       "Enter Name", JOptionPane.QUESTION_MESSAGE);
    int amount = 100;//player starts with 100 dollars
    final int GOAL = 300;  //player needs to reach 300 dollars          
} //end of DicePlayer class
[\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

And to help you one step further (feeling generous), make your
winBet method like this:
private int winBet(int bet, int amount){
    return amount + bet;
}then the call the jfbriere gave you will work.
amount = winBet(bet, amount);
But maybe you figured all this out already?

Similar Messages

  • I'm having trouble updating my iphone 4 since i updated to 4.3.3 i can't update it anymore. right now when i connect it to my itunes, itunes freezes for about 5 minutes then says something like "could not load sync service" any ideas on what i shud do?

    I'm having trouble updating my iphone 4 since i updated to 4.3.3 i can't update it anymore. initially itunes would let me go so far as downloadin the new software then an error poped up as soon as the download finished, and now when i connect it to my itunes, itunes freezes for about 5 minutes then says something like "could not load sync service, reconnect or try again later" any ideas on what i shud do?

    Did you try to connect in recovery mode? iPhone and iPod touch: Unable to restore

  • HI there, I am having trouble updating my CS5 Master's Collection Suite for at least a month now. I keep gettin this message "There was an error downloading this update. Please quit now and try again later" every time and do not know how to fix it.

    I am having trouble updating my CS5 Master's Collection Suite for at least a month now. I keep getting this message "There was an error downloading this update. Please quit now and try again later" every time and do not know how to fix it.
    Any help will be highly appreciated.
    Thanks a lot in advance.
    Sincerely,
    Uvaldocj@@
    Here is a list of the products I am troubled with:
      Adobe After Effects CS5 10.0.2 Update
    There was an error downloading this update. Please quit and try again later.
      Adobe Bridge CS5 4.0.5 Update
    There was an error downloading this update. Please quit and try again later.
      Adobe Extension Manager CS5 5.0 Update
    There was an error downloading this update. Please quit and try again later.
      Adobe Illustrator CS5 15.0.2 Update
    There was an error downloading this update. Please quit and try again later.
      Adobe Pixel Bender Toolkit 2.5 Update
    There was an error downloading this update. Please quit and try again later.
      Adobe® InDesign® CS5 7.0.4 update
    There was an error downloading this update. Please quit and try again later.
      Dreamweaver CS5 11.0.4 Updater
    There was an error downloading this update. Please quit and try again later.
      Fireworks CS5 11.0.2 Update
    There was an error downloading this update. Please quit and try again later.
      Photoshop 12.0.4 update for Photoshop CS5
    There was an error downloading this update. Please quit and try again later.
      Photoshop Camera Raw 6.7 Update
    There was an error downloading this update. Please quit and try again later.

    I'm having the same issue. And Dreamweaver now crashes after just a few seconds.

  • I have 2 App Store accounts, one from MobileMe time and i want to know if it is possible to merge them as i'm having troubles updating some of my software?

    I have 2 App Store accounts, one from MobileMe time and i want to know if it is possible to merge them as i'm having troubles updating some of my software?
    I have to sign in and out between one and the other constantly and i dont know what to do anymore becouse now i can't update software on either, it keeps on poping up "To update this application, sign in to the account you used to purchase it." and im pretty sure im on the right account.

    Sorry. Apple's policy states that accounts cannot be merged > Frequently asked questions about Apple ID
    Contact Apple for assistance > Contacting Apple for support and service

  • TS4006 Hi I am having trouble updating my apps I have tried one at a time and all together but they just will not load any ideas would be appreciated

    Hi, I am having trouble updating my apps, I have tried one at time and all together but they just keep on whirring away and nothing happens! any ideas woud be appreciated.

    Suggest you update all these apps on iTune (computer) and sync them to your iPad.

  • HT1222 Having trouble updating to  11.1 on my iPhone 5 and I can't download any music from iTunes to my iPhone because it says I don't have 11.1

    Having trouble updating to  11.1 on my iPhone 5 and I can't download any music from iTunes to my iPhone because it says I don't have 11.1? How can I update iTunes on iPhone?

    You update iTunes on your computer to 11.1.

  • Checking for an updated variable value in symbol timeline

    I'm making a puzzle which involves moving crates in a specific order to get a character from one side to the other. Take a look at http://tinyurl.com/c4vwcj9 to get the gist of it.
    Each crate is a symbol with it's own timeline. A crate may only move a pre-determined direction and distance once clicked. No more than 2 crates can be pulled out of the grid at any one time.
    The timeline of each symbol has three states: "Original", "Moved" and "Returned".
    If you have a play around with the puzzle as it stands so far, you will see most of the logic arguments work ok. However, the problem I have is when you pull a crate out of the grid and it needs to check if it can move back into place.
    To see what I mean:
    - Pull out the bottom left corner crate
    - Move the crate to the immediate right, thereby blocking the previous crate
    - Try to move the bottom left corner crate again (you should get an error message and it shouldn't move - this is fine)
    - Move the other crate back to it's original position to unblock the previous crate
    - Try to move the bottom left corner crate a final time (you still get the error message and it doesn't move - this is not fine!)
    A quick debug has revealed the second mouse click doesn't fetch the updated variable AFTER the symbol timeline begins to play, but the same methodology works just fine for crates that check for impeded movement BEFORE a symbol timeline is played (try one of the inner crates). Why isn't it getting the updated value and what can I do to solve it?
    Below is a sample of the code specific to the bottom left crate. I've highlighted the variable and arguments specific to the problem. Please excuse what is no doubt poor Javascript coding conventions - I only started learning this last week!
    //-- Get needed variables
    // Check to see if other crate is impeding movement and define value as a variable
    var myCrateCheck = sym.getComposition().getStage().getSymbol("_b_2x1crate_h").getVariable("Crate2");
    // Check to see what this crate's status is and define value as a variable
    var mySelfCheck = sym.getComposition().getStage().getSymbol("_bl_3x1crate_h").getVariable("Crate1");
    // Check to see if other crates have been moved out of the main grid. Parse value as an integer in base 10.
    var myGridCheck1 = parseInt(sym.getComposition().getStage().getSymbol("_br_2x1crate_v").getVariable("Crate3_ grid"),10);
    var myGridCheck2 = parseInt(sym.getComposition().getStage().getSymbol("_bl_4x1crate").getVariable("Crate4_gr id"),10);
    var myGridCheck3 = parseInt(sym.getComposition().getStage().getSymbol("_bl_2x2crate").getVariable("Crate5_gr id"),10);
    var myGridCheck4 = parseInt(sym.getComposition().getStage().getSymbol("_cl_2x1crate_h").getVariable("Crate9_ grid"),10);
    var myGridCheck5 = parseInt(sym.getComposition().getStage().getSymbol("_cl_1x1crate_1").getVariable("Crate13 _grid"),10);
    var myGridCheck6 = parseInt(sym.getComposition().getStage().getSymbol("_cr_3x1crate_h").getVariable("Crate16 _grid"),10);
    var myGridCheck7 = parseInt(sym.getComposition().getStage().getSymbol("_tl_2x1crate_h").getVariable("Crate17 _grid"),10);
    var myGridCheck8 = parseInt(sym.getComposition().getStage().getSymbol("_tc_2x2crate").getVariable("Crate18_g rid"),10);
    var myGridCheck9 = parseInt(sym.getComposition().getStage().getSymbol("_tr_2x1crate_h_1").getVariable("Crate 19_grid"),10);
    var myGridCheck10 = parseInt(sym.getComposition().getStage().getSymbol("_tl_3x1crate_h").getVariable("Crate20 _grid"),10);
    var myGridCheck11 = parseInt(sym.getComposition().getStage().getSymbol("_tr_2x1crate_h_2").getVariable("Crate 21_grid"),10);
    // Create a variable called myGridCheckSum, make sure it's a number and sum the above
    var myGridCheckSum = 0;
    myGridCheckSum = myGridCheck1 + myGridCheck2 + myGridCheck3 + myGridCheck4 + myGridCheck5 + myGridCheck6 + myGridCheck7 + myGridCheck8 + myGridCheck9 + myGridCheck10 + myGridCheck11;
    //-- Logic & Conditional Statements
    // If this crate is in any position other than "Moved", and more than 1 box is already out of grid zone - prevent move and alert
    if ((mySelfCheck != "Moved") && (myGridCheckSum >1)){
    alert('Too many boxes outside of grid zone');
    sym.stop();
    // Or else, if this crate is in any position other than "Moved", but less than 2 boxes are out of grid zone - allow move
    else if ((mySelfCheck != "Moved") && (myGridCheckSum <2)){
    sym.play();
    // If this crate has moved but the other crate hasn't moved, play remainder of symbol timeline
    else if ((mySelfCheck == "Moved") && (myCrateCheck != "Moved")){
    sym.play(3001)
    // If this crate has moved and the other crate is also moved, alert and loop back on timeline
    else if (myCrateCheck == "Moved"){
    // Alert user to say crate cannot be moved
    alert('This box is being blocked by another!');
    sym.play(2999);

    Resolved. Silly little syntax error on a variable rewrite on another symbol!

  • I am having trouble updating the operating system on both my ipad and iphone. I get a strange message when I open my PC desk top that says "the procedure entry point sqlit3_wal-checkpoint could not be located in teh dynamic link library SQLite3.dll"

    I am having trouble updating my operatI am having trouble updating the operating system on both my ipad and iphone. I get a strange message when I open my PC desk top that says "the procedure entry point sqlit3_wal-checkpoint could not be located in the dynamic link library SQLite3.dll"  Any ideas what my problem is?

    Hi whatsthe77,
    Welcome to Apple Support Communities.
    You may want to follow the steps in this article to reinstall iTunes:
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    http://support.apple.com/kb/HT1923
    Have a great day,
    Jeremy

  • Trouble updating to iOS 5 on my wife's iPhone 4 connected to our iM, right before download finishes downloading iTunes comes back with the error message Software corrupted during download.  Please check network settings and try again later.

    Trouble updating to iOS 5 on my wife's iPhone 4 connected to our iM, right before download finishes downloading iTunes comes back with the error message Software corrupted during download.  Please check network settings and try again later, however there was no problem updating my iPhone to iOS 5 through iTunes connceted to my dell laptop on the same wireless network.  What gives?

    Try disabling your firewall; both on your PC and the external Firewall/Router.

  • I am having trouble updating iTunes 10.7- it downloads about 70% then stops and says error. What can I do to update??

    I am having trouble updating iTunes 10.7- it downloads about 70% then stops and says error. What can I do to update??

    I'd first try downloading an installer from the Apple website using a different web browser:
    http://www.apple.com/quicktime/download/
    If you use Firefox instead of IE for the download (or vice versa), do you get a working installer?

  • Why am i having trouble updating itunes  on my windows 7 (64 bit) computer?

    Why am I having trouble updating itunes on my windows 7 (64 bit) computer?

    Doug
    Thanks for the update.
    nothing is getting installed, copied or otherwise loaded onto my computer....first the program starts to load, then it asks for my serial number, then it goes out and seems to check the serial number then it says it can't be installed then it erases everything it just spent 10 minutes loading.
    In view of the above and your prior descriptions, have you tried alternative installation files?
    If you want to give a look to that approach, please download and install the tryout files for Premiere Elements 9 from the following web site and then insert your purchased serial number into them during installation.
    With this route, you need to carefully carry out the web site's "Note: Very Important Instructions" in order to avoid an Access Denied message.
    Photoshop Elements 9 / Premiere Elements 9 Direct Download Links | ProDesignTools
    Back to my questions from post 3
    Are you getting any Shared Technologies error message any where in the installation process that is failing?
    If you follow the following path, do you find an OOBE Folder?
    Local Disk C
    Program Files (x86)
    Common Files Folder
    Adobe
    and in the Adobe Folder should be the OOBE Folder which you rename from OOBE to OLDOOBE to disable it.
    When you are forced into a roll back for whatever installation has taken place, do you ever see a message about Shared Technologies?
    And, whether or not the program installs to any extent, does your computer have the OOBE Folder? If so, then please rename it to disable it before
    you try for another 9 install.
    Looking forward to your results.
    ATR
    Add On....Please remind me....since you purchased Premiere Elements 9, have you ever installed and used it successfully on any computer?

  • MQ:OSB Assign action failed updating variable "ServiceRequest"

    Hi
    We have a problem with the MQ adapters in Oracle Service Bus.
    If we (by accident/break testing) put messages on the queue that are invalid XML (such as "Banana" as plain text), the OSB goes into an infinte loop with this message, as it can never be dequeued due to:
    <BEA-381901> <Exception in MQ Inbound Request: TransportException EndPoint: T20230_GoodsEvent/ProxyServices/T20230_G
    oodsEvent, com.bea.wli.sb.transports.TransportException: OSB Assign action failed updating variable "ServiceRequest": com.bea.wli.common.xquery.XQueryException: Error parsing XML: {err}FORG0
    005: expected exactly one item, got 0 items
    com.bea.wli.sb.transports.TransportException: OSB Assign action failed updating variable "ServiceRequest": com.bea.wli.common.xquery.XQueryException: Error parsing XML: {err}FORG0005: expect
    ed exactly one item, got 0 itemsThis even prevents the message from being put on the dead letter queue.
    Any hints?

    Correct, but we have tried switching to Text to no avail.

  • Having trouble updating to latest Mavericks update

    Is anyone having trouble updating their older iMac to the latest Software Update? I am getting a hanging "Preparing OS X Update" screen that goes nowhere after much waiting. Tried downloading again and still not installing.

    Hello TripletDad
    If the update is not taking, then reinstall OS X Mavericks. As a precautionary, I recommend backing up before you go through with that reinstallation, even though it will not erase anything.
    OS X Mavericks: Reinstall OS X
    http://support.apple.com/kb/PH13871
    Regards,
    -Norm G.

  • Having trouble updating Elements Organizer 11

    Having trouble updating Elements Organizer 11.  I started it using Administrator priveleges, disabled firewall but keep getting "The update server is not responding. The server might be offline".  I am using Windows 8.1 x64.  My current version is 11.0.0.0.  I read that you may need to go into Adapter Settings and disable:
    Microsoft Virtual WiFi Miniport Adapter
    Microsoft Wi-Fi Direct Virtual Adapter
    Microsoft Hosted Network Virtual Adapter
    but I didn't see those listed! Help!

    Very frustrated!  What do you mean by "focusing on my host files"?  Every other reputable software company I know of has direct downloadable updates in case their "update manager" doesn't work, so I'm not sure why Version 11 of PSE doesn't have this capability.  I need to get my software updated!  Please help me (and I'm not the only one) get this working so I can move on to greater things.  Please be specific (I'm pretty good with computers so don't be shy).

  • Having trouble updating my ipad

    having trouble updating my ipad comes up with an error msg 3259 and a network timed out msg. im using windows vista and i have followed the instructions on the apple site about turning of all my firewalls but still having no luck with updating to 4.2. i have also tried a system reset (holding the power and the square button together)

    Have you tried temporarily disabling any antivirus/antispyware software on your computer? Those often block updates.
    Hope this helps.

Maybe you are looking for

  • Why does iMac (Mid 2012) not support Jumbo Frames?

    Why is it not possible to change MTU size to more than 1500? Buying such a high quality product, I would expect that it supports jumbo frames! My NAS supports jumbo frames, the Air Port Extreme does but a brand new iMac doesn't??? Is there any patch

  • Unable to adjust or export images

    After importing my last batch of RAW images, I find that I can't adjust or export any of them. I can't externally edit in Photoshop either. If I drag the image to Photoshop, I get a reduced sized jpeg as it is presumably only a preview. (By the way,

  • Iphone stuck on 'plug into itunes' symbol - even after hard reboot

    Deciding to update my iphone 3G with the most current version release, my computer 'blue screened' while putting the updates on the iphone. Now my computer does not recognise any operating system (not good!) and my iphone (even after hard reboot) doe

  • When I try to duplicate a slide or copy a slide I am booted out of Captivate 8.

    Unfortunately, I am not given the opportunity to save before Captivate closes.

  • 10g Datagaurd

    Hi, Can any one tell me how to configure the 10g datagaurd with enterprise grid control. i install the 10g on windows on one PC and Grid control on other PC. So how to i use the grid control to configure the Datagaurd. Regards