Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7680431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:06:47+00:00 2026-05-31T18:06:47+00:00

Homework: Rock Paper Scissors game. I’ve created an enumeration: enum Gesture{ROCK,PAPER,SCISSORS}; from which I

  • 0

Homework: Rock Paper Scissors game.

I’ve created an enumeration:

      enum Gesture{ROCK,PAPER,SCISSORS};

from which I want to compare values to decide who wins–computer or human. Setting the values works just fine, and the comparisons work properly (paper covers rock, rock crushes scissors, scissors cuts paper). However, I cannot get my tie to work. The user is declared as the winner any time there’s a tie.

Ahhh…crap…this will clarify: userPick is a String with values rock, paper, or scissors. I’m unable to use == to compare userPick to computerPick, which, as you can see below, is cast as type Gesture from my enum.

      if(computer == 1)
         computerPick = Gesture.ROCK;
      else
         if(computer == 2)
           computerPick = Gesture.PAPER;
         else
           computerPick = Gesture.SCISSORS;
      if(userPick.equals(computerPick))
       {
          msg = "tie";
          ++tieGames;
       }
           etc....

I am guessing that there’s an issue with rock not being equal to ROCK, or the String userPick not being able to match Gesture computerPick because the latter isn’t a String. However, I’m not able to find an example of a similar circumstance in my textbook or Oracle’s Java Tutorials, so I’m not sure how to correct the problem…

Any hints?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:06:48+00:00Added an answer on May 31, 2026 at 6:06 pm

    I’m gathering from your question that userPick is a String value. You can compare it like this:

    if (userPick.equalsIgnoreCase(computerPick.name())) . . .
    

    As an aside, if you are guaranteed that computer is always one of the values 1, 2, or 3 (and nothing else), you can convert it to a Gesture enum with:

    Gesture computerPick = Gesture.values()[computer - 1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For homework we are suppose to progrma a pig game which adds up to
I have a homework assignment which asks to have the user input a date
newbie doing Java homework here. I have one class named Album which contains the
This is a homework question from compiler design course. I just need an explanation
I have a prolog homework, which should work like this: singles([1,2,3,2,2,4,1], [3,4]). true Now
I have a homework assignment to write a multi-threaded sudoku solver, which finds all
Homework. Dice Game. I've got an array that represents five rolls of a die.
my homework assignment was to: write a function called findPattern() which accepts two strings
For homework I want to draw circles randomly around the screen. If any of
For homework, I was given the following 8 code fragments to analyze and give

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.