-4

I Am using Createjs/Java to create a guessing game. My game is nearly complete but my last thing that I would like to do would be to check to see if the same guess has been entered twice

    var result = 0;
    // check for matches
    if (myGuess > targetNumber) {
        result = GuessResult.LOWER;
    } else if (myGuess < targetNumber) {
        result = GuessResult.HIGHER;
    } else if (myGuess == targetNumber) {
        // player is winner
        result = GuessResult.WINNER;
    }

    if ((guessesUsed == 10) && (result != GuessResult.WINNER)) {
        // player is loser
        result = GuessResult.LOSER;
    }

    return result;
}
Tunaki
  • 132,869
  • 46
  • 340
  • 423
MrScotia
  • 1
  • 2
  • 1
    So what part of that don't you know how to do? – Joseph Sible-Reinstate Monica Mar 03 '17 at 19:14
  • It take's the same number twice as a guess, but what I would like to do is make an array that will check for double guess's , so that you cannot guess the same number twice – MrScotia Mar 03 '17 at 19:16
  • 1
    I understand that's what needs to be done. I'm asking what part of doing that you're stuck on. – Joseph Sible-Reinstate Monica Mar 03 '17 at 19:16
  • 1
    @MrScotia Because as it stands, you seem to be wanting us to do you work for you. Do you have a specific question? – Carcigenicate Mar 03 '17 at 19:18
  • 1
    Also, your question states "`Java`" as the technology but the tags you have are for `JavaScript` -- please note that `Java` and `JavaScript` are two different languages. Despite being similarly named remember not to conflate the two. – Alexander Nied Mar 03 '17 at 19:20
  • I am trying to make it so that it cannot guess the same number twice, i cannot figure out how to do this – MrScotia Mar 03 '17 at 19:21
  • 1
    @MrScotia Repeating the requirement doesn’t help here. What have you tried to implement this? Do you have any code where you have attempted to implement your requirement? What is the specific thing that stopped you from continuing or beginning? – Sebastian Simon Mar 03 '17 at 19:24
  • @MrScotia Put all the previous guesses in an array. Then just use `indexOf` to see if the new guess is in the array. What's so hard about that? – Barmar Mar 03 '17 at 19:31
  • Extremely new to programming, I am not sure how to write a array, but will try thanks! – MrScotia Mar 03 '17 at 19:39

1 Answers1

1

My apologizes to admins of Stack Overflow for not posting an actual answer - MrScotia: Posting homework assignments to stack overflow in the hopes of someone presenting a working solution is not demonstrating learning outcomes. This is a violation of the academic code of conduct. If you do it again, the entire assignment will be replaced with an in class exam - and I will be sure to inform your classmates who to thank. I trust this account will no longer be used for cheating purposes...