Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    if(play == null)
    {
    // The user has asked to quit
    // >>>> add program quitting logic here<<<<

    }
    else
    {
    x = Integer.parseInt(play)
    }
  2. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    Yes the code would be like that so it would not call the parseInt() method with a null value.

    The (play!=null) test is redundant. The (play==null) test in the if guarantees that play will not be...
  3. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    What is the "it" you are asking about?
  4. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    The value of the variable passed to the parseInt() method on line 48 was null. The code should test the variable's value before passing it the the parseInt() method. The code in post#9 is wrong. ...
  5. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    Use the println() method to print out the value of the variable that was assigned what was returned by the method (play in the above code).


    Please explain what happened.
  6. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    Is null what is returned to the play variable when the user clicks cancel?
    Then the code you posted would detect that:

    play = JOP.sIP("dialog")

    if(play == null)
    {
    // The user has asked to...
  7. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    How do you know if the user has quit? What does the user enter that says "I quit"?
    Can the program then test for that input from the user and do what you want done?

    There are two issues:...
  8. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    Can you post the line of code that is giving the error message?
    Also say what data types all the variables in that line are.
  9. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    boolean variables can have the values: true or false
  10. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    Several choices: set a boolean variable and exit the loop the code is in. Outer loops need to check the boolean to see if the code is to exit.
    Call the System.exit(0) method to end the program's...
  11. Thread: Bagels game

    by Norm
    Replies
    23
    Views
    4,917

    Re: Bagels game

    The problem with using ORs to connect expressions in a large condition is that if any one is true the condition is true.
    If you want all of the subexpressions to be true, use ANDs
Results 1 to 11 of 11