Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

I keep getting null

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I’m working on a homework assignment to make a rock paper scissors game. I have made the main file and now I’m working on the class file. When I try to get it where value == 1 then pick = “Rock” and so on.
Then I want to output what pick is. I get null? Why? Here is my code.




Thank you for any help on this.
 
Saloon Keeper
Posts: 7066
165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apparently the value is not 1. I'd start by examining what value it has, maybe by inserting another System.out.println statement.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DoYourOwnHomework .
dude, Ask question yourself what could be the reason ? and list out your understanding; and not able to figure out ? approach your teacher . your teacher is not able to answer? ... definitely she/he should know about this assignment . in case she/he dont know the clue. come back we will give you a hint

 
Marshal
Posts: 22394
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check when you're setting the value of pick. In which methods is it set, and when are those methods called.
 
Adam Burda
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im sorry i forgot to enter all of the code the first time. here is the class Game file again with all if statements.

 
Tim Moores
Saloon Keeper
Posts: 7066
165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You apparently haven't done this yet:

Rob Spoor wrote:Check when you're setting the value of pick. In which methods is it set, and when are those methods called.

 
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic