• 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

Zuul Locked Door

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ex. 6.44: Add locked exits to your game. The player needs to find (or otherwise obtain) a key to unlock the exit and enter a room. (You don't need to add a new class for doors or exits to your game). Make this as general as possible - in any room, any exit could potentially be locked.

I have no idea how to do this. One idea was to make a HashMap with direction as keys and boolean (true/false) as values. Any suggestions?

 
Marshal
Posts: 73970
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start by explaining in words of one syllable how you are going to unlock the door. Write it down with a pencil (so you can destroy the evidence when you get it wrong ‍). See where that leads you.
 
Chan Duller
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, one room could have the key item stored in it. So when you reach that room, you can collect it and use it to unlock the exit that is locked.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic