• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with Java game

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i have an issue where my programs output is returning false in comparison to the benchmark output for an assignment I'm doing (can be seen in attachment below), I was wondering if anyone knows what I did wrong?, I put a comment with // below on what I think went wrong but I'm still unsure why the method isChestUnlocked returning false, maybe instead of referring to jar1 in class ground, I have to refer to jar1, jar2 and 3 in class Chest instead?, if so how do I do this since the variables have to be private.


Webp.net-resizeimage.png
[Thumbnail for Webp.net-resizeimage.png]
Benchmark on the left, my Programs output on the right
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're missing a closing brace for your class Jar. You might want to fix that first and retry.
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and Welcome to the Ranch!

Can you tell us what how that benchmark program is being run? Is that in JShell or some other interactive REPL-like for Java? I ask because I find this intriguing:

That won't work unless the chess, jar1, and stone fields are public. If they're private, I'd expect some kind of access error to be reported.
 
Jules Val
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:and Welcome to the Ranch!

Can you tell us what how that benchmark program is being run? Is that in JShell or some other interactive REPL-like for Java? I ask because I find this intriguing:

That won't work unless the chess, jar1, and stone fields are public. If they're private, I'd expect some kind of access error to be reported.



I'm not sure, but we are using a program called Blue J for our code.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic