Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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
 
Marshal
Posts: 16601
278
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
Marshal
Posts: 16601
278
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic