I am trying to make a guessing game that lies one-third of the time that the guess is too high (it says it is too low when it is actually too high). And it never lies about the guess being too low, nor does it lie twice in a row

This is my code but I don't know how to code the showUpdatedStatus() method

import javax.swing.JOptionPane;

public class Exercise4_28 extends BasicGame
 { private java.util.Random randy;
   private int itsSecretNumber;
   private int itsUsersNumber;

  public Exercise4_28()
     { super();
       randy = new java.util.Random();

  public void askUsersFirstChoice()
    { itsSecretNumber = 1 + randy.nextInt (100);

  public void askUsersNextChoice()
    { String s = JOptionPane.showInputDialog
         ("Guess my number from 1 to 100:");
      if (s != null && ! s.equals (""))
         itsUsersNumber = Integer.parseInt (s);
         itsUsersNumber = -1;

  public boolean shouldContinue()
    { return itsUsersNumber != itsSecretNumber;

  public void showUpdatedStatus()
    { Random chance = newRandom();
      if (chance == 1)
        { JOptionPane.showMessageDialog (null, "Hot");            
        { JOptionPane.showMessageDialog (null, "Warm");

Add a field that remembers whether last time was a lie. Compare itsUsersNumber and itsSecretNumber to see if itsUsersNumber is too low or two high. If chance == 1, the guess is too high, and last time wasn't a lie then lie and record that you lied. Otherwise, show the true message and record that you didn't lie.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.