All searchable game objects are similar in the sense that they have a description and they may or may not contain a clue as to what the code could be.
Lets start with a backpack as a searchable object. The function header for a searchable object will look like this.
public static void backpack(int choice, int code_location, int code_value);
Here choice is the choice we made in the room of objects. code_location is the location of the code in the list of objects. code_value is the actual value of the digit.
A simple function for backpack might look something like this.
public static void backpack(int choice, int code_location, int code_value) {
System.out.println("");
System.out.println("The backpack is your personal bag. Strange. You thought you lost it weeks ago.");
if (choice == code_location) {
System.out.println("Within the front pocket, you see the number" + code_value + " written on a crumpled note.");
System.out.println("");
}
else {
System.out.println("You find no code.");
System.out.println("");
}
}
This template can be followed for all searchable objects. More functiality could be added. For exaple, you could make an object like the door so it requires a code. Perhaps you need to search a safe to find part of the door code. As always you are encourages to make changes and be creative.