Skip Top Navigation Bar

Escape Room Code Decoding

An escape maze is comprised of multiple rooms. In each room, you will find a code to lead you to the next room. The code is a String comprised of:

There are no spaces in the code.

For example,

TIME-415-CLOCK

The mission clue, in this case TIME, is reported to aid in finding the code in the next room.

The lock code, in this case 415, will tell the team to go to the next room on the right if a positive value is returned when it is compared to the master lock code or to the left if a negative value is returned when it is compared to the master lock code. If 0 is returned when it is compared to the master lock code, the team has won and can exit the game.

The clearance word, in this case CLOCK, allows the Team to automatically win if the clearance word matches the master clearance word.

You will write a program to determine whether the team can exit based on the lock code and clearance word. Regardless, you will print a report that includes:

Code Generator

Master codes are represented by the CodeGenerator.java class and only include a lock code and clearance word. They do not include a mission clue. You will only use the CodeGenerator.java class to generate the master code. A master code is generated at the start of each game. Refer to the CodeGenerator Documentation or the table below to understand the attributes and behaviors of a CodeGenerator object and how to create them.

Class Name: CodeGenerator Class
Constructors:
  • CodeGenerator() - randomly generates the master code
  • CodeGenerator(int lockCode, String clearance) - use when testing
Data/Attributes:
  • int lock;
  • String clearance;
Methods/Behaviors:
  • int getLockCode()
  • String getClearanceWord()

Algorithms and Planning

You will write a program to do the following:

Develop Test Cases

Before you write your code, determine a set of test master codes and room codes as well as the results. Be sure to provide tests for all scenarios:

To avoid attempting to test with a random master code, you will want to use the two parameter constructor for CodeGenerator when testing your code.

Develop an Algorithm

Develop algorithms to address each task in this project:

Write Your Program in the Java Playground

We have included the CodeGenerator class in this iteration of the Java Playground. When using the Java Playground do not include the header of the main method, just the body.

Write Your Program in an IDE

You will have two .java files for this program. It is best practice to create a project folder for both of these files to be stored together.