Mandatory Case
Java1BP
Periode Berlaku Semester Genap 2018/2019 Software Laboratory Center
Valid on Even Year 2018/2019 Assistant Recruitment 19-2
Soal
Case
Meong : The mAWlink
After seeing Jewel Quest game, you are interested to create a simple game but in different genre
with different language. The language you will use is Java because you want to polish your skill in Java
programming language. Meong the Mawlink is an interactive fictional game that is similar to other game
with the same genre such as Zork and Collosal Adventure Game.
In the story, the main character is a genius cat, named Meong, who can do all things that human can
do. The cat become bored and want to steal some treasure that his owner has. The objective of the game is
to steal two treasures that his owner has. Meong is failed when he used all his turn and still didn’t collect
the two treasures because the owner will be back, and he cannot steal anything anymore.
First, the program will load ‘[Link]’ and ‘[Link]’ to initialize the game component. To create the
game, you need two main components which are item and room.
➢ Item
To support a very detailed game, we need to store a lot of data. Below is the table about data that
will be stored and its description.
Detail Description
Name The item’s name.
Description The item’s brief description.
Location The item’s room location.
Indicates whether the player can take the item or not. True if the item is
Portable
portable and false is the item is not portable.
Indicates whether the item can contain another item or not. The value can be
Container
0, -1 or container name. 0 indicates that the item is a container and -1 indicates
Halaman : 1 dari 17
Page 1 of 17
the item is not in any container. If the value is a container name. Then the item
is contained by the described container.
Specify whether there is a required item to examine this item. -1 indicates that
Required the item is not require anything to examine and a string indicates the item that
required to examine this item.
Specify whether the item is a treasure to be found or not. True if the item is a
Treasure
treasure, False if the item is not a treasure.
Note that you can add your own item’s detail. The item’s data is stored in a file named “[Link]”.
The data in [Link] will be written in format below.
Name;Description;Location;Portable;Container;Required;Treasure
➢ Rooms
Room’s data only consist of the room name and room description. The room’s data is stored in a
file named “[Link]”. The data in [Link] will be written in format below.
RoomName;RoomDescription
Before the player can play the game, the program must generate the map first. The map consists
of six room:
➢ Bedroom A
➢ Bedroom B
➢ Kitchen
➢ Living Room
➢ Storage Room
The location of the room is random, but Bedroom A will always be the initial room where the
game begun. Also, the room must be connected to other room logically. For example, if in the east of
bedroom A there is bedroom B, in the south of bedroom B is the kitchen, and finally in the west of
kitchen is storage room. Logically, we must connect bedroom A and storage room, the storage room
is in the south of bedroom A.
Halaman : 2 dari 17
Page 2 of 17
1. Play Game
When the game start, program will display the current room the player in, and the bot will
describe the room plus the room navigation. Meong has 15 turns to accomplish the mission. The
program will also display the turn Meong has left. The bot will prompt player to type the command
until the state of the game is lose or win.
Because you want to create this game as a console game, you cannot use GUI to do an action
related in the game. That’s why all action would be done in a command. To help user with the
command, you want to create a simple bot with AI that will help user through the game. The
command used for the game will be described below.
➢ Take
The player will use the verb ‘take’ to get an item and store it in Meong’s inventory.
• The ‘take’ verb must be paired with other word.
• The paired word is an item that exists.
• You cannot take more item when the inventory is full. Maximum inventory capacity is 4
items.
Halaman : 3 dari 17
Page 3 of 17
• Before you seen an item (directly or through examine) you cannot take the item.
• You cannot take an item that’s already in your inventory.
• Item taken must be portable.
• Item taken must be in the current room.
• Because the turn’s is limited, the bot permits you to take more than one item. To do that,
player can type the verb Take followed by the list item to take.
• When the item is taken, the item will be stored in your inventory.
Halaman : 4 dari 17
Page 4 of 17
➢ Examine
The player will use the verb ‘examine’ to view a specific item in a narrative manner.
• The ‘examine’ verb must be paired with other word.
• The paired word must be an item that exists.
• The examined item must be in the current room.
• If there’s any item required to examine the item, then validate the required item must
be in the inventory.
• When the item is examined, the bot will explain you in detail about the item you want to
examine.
Halaman : 5 dari 17
Page 5 of 17
➢ Drop
The player will use the verb ‘drop’ to take out an item from his inventory.
• The ‘drop’ verb must be paired with other word.
• The paired word must be an item that exists.
• The item user wants to drop must be in the inventory.
• Because the turn’s is limited, the bot permits you to drop more than one item. To do
that, player can type the verb Drop followed by the list item to drop.
• After the item is dropped, the item’s will be in the initial location.
Halaman : 6 dari 17
Page 6 of 17
➢ Go
Player use the verb go to move to another room.
• The ‘go’ verb must be paired with other word.
• The go verb can only be followed by West, North, East, and South.
• Validate there is a room based on the direction in player’s command
➢ Inventory
Player use the inventory command to view list of items that stored in his inventory.
Halaman : 7 dari 17
Page 7 of 17
➢ Suggestion
After designing the game, you want to improve the ability of your bot. Therefore, you
want to add feature that will help user to play the game. The feature is a word suggestor,
suppose that you type a wrong word “boook”, the bot will suggest you several word that
simmilar to the word inputted based on the words in the dictionary. For example, in our
dictionary there is a word “book,” “bookshelf,” and “dragon”. Based on similiarity, the book and
bookshelf will be recommended to the player and the word “dragon” will not be recommended
to the player. This feature will be applied to all input that related to in-game item in the play
game menu.
You have to sort the list using merge sort based on the word similarity. To determine
which word more similar to another word, you may want to play the game and find “Book” item
and read the description for a hint in making this feature. In this case, “book” is more similar to
“boook” than “bookshelf”.
2. Design Game
To make the game more dynamic, the user will have a privilege to design his/her own game.
In this menu, player will have three privileges, that is to add, update, and remove item from the
game. When player choose this menu, the player will be prompt to input which room he/she want to
modify. Player can redo this action by choosing the sixth menu, back.
After the player choose the room, the bot will ask player whether he/she want to add, update, or
remove item in the room. When player is not input a correct string, the bot will prompt it again.
Halaman : 8 dari 17
Page 8 of 17
2.1 Add
If the player chooses the add menu, prompt the player to insert an item name.
• Validate that the item name must be unique and haven’t been used before.
• After that, the bot will prompt the player to insert item description. Validate that the item
description’s length must be between 15 – 50 characters.
• Then the bot will prompt the player to state whether the item is portable or not. Validate
that the input must be yes or no (Case Insensitive).
• After that the bot will prompt the player to state whether there is an item required to
examine this item. Validate that the input must be yes or no (Case Insensitive).
• If the player choose yes, then display all item’s that can be taken to inventory (portable) and
prompt user to input item name. Validate the item’s name inputted must be portable and
exist.
Halaman : 9 dari 17
Page 9 of 17
• After that the bot will prompt the player to input where the item will be placed. Validate the
container’s name is an item in the room that is a container and exist.
• Because the player add a new item in the container, he/she might want to change the
description of the container item. Therefore, the bot will prompt the player to input whether
the user wants to update the item’s description or not. Validate the input must be yes or no
(Case Insensitive).
Halaman : 10 dari 17
Page 10 of 17
• If the player chooses yes, then the bot will prompt the player to input new description.
Validate the new description’s length must be between 15 – 50 characters.
• After that the bot will prompt the user whether to modify other items or not. Validate the
input must be yes or no (Case Insensitive).
Halaman : 11 dari 17
Page 11 of 17
• If the player choose no, then the player will be prompt again to choose whether to add,
update, or remove item.
• If the player choose yes, then proceed to the next step. Because the player modify the item in
the room, he/she might want to change the description of the room. Therefore, the bot will
prompt the player to input whether to update the room’s description or not. Validate the
input must be yes or no (Case Insensitive).
• If the player chooses yes, then the bot will prompt the user to input new description of the
room. Validate the new description’s length must be between 15 – 50 characters.
• After that the player will be back to the design menu.
Halaman : 12 dari 17
Page 12 of 17
2.2 Update
If the player choose update, then the bot will display all item in the chosen room.
• After that the bot will prompt the user to insert item’s name. Validate the input must be item
in the room and exist.
• After choosing an item, the bot will prompt the user to insert a new description for the item.
Validate that the item description’s length must be between 15 – 50 characters.
• Then the bot will prompt the player to state whether the item is portable or not. Validate
that the input must be yes or no (Case Insensitive).
• After that the bot will prompt the player to state whether there is an item required to
examine this item. Validate that the input must be yes or no (Case Insensitive).
• If the player choose yes, then display all item’s that can be taken to inventory (portable) and
prompt user to input item name. Validate the item’s name inputted must be portable and
exist.
Halaman : 13 dari 17
Page 13 of 17
• After that the bot will prompt the player to input where the item will be placed. Validate the
container’s name is an item in the room that is a container and exist.
• Because the player update an item in the container, he/she might want to change the
description of the container item. Therefore, the bot will prompt the player to input whether
to update the item’s description or not. Validate the input must be yes or no (Case
Insensitive).
• If the player chooses yes, then the bot will prompt the player to input new description.
Validate the new description’s length must be between 15 – 50 characters.
Halaman : 14 dari 17
Page 14 of 17
• After that the bot will prompt the user whether to modify other items or not. Validate the
input must be yes or no (Case Insensitive).
• If the player choose no, then the player will be prompt again to choose whether to add,
update, or remove item.
• If the player choose yes, then proceed to the next step. Because the player modify the item in
the room, he/she might want to change the description of the room. Therefore, the bot will
prompt the player to input whether to update the room’s description or not. Validate the
input must be yes or no (Case Insensitive).
• If the player chooses yes, then the bot will prompt the user to input new description of the
room. Validate the new description’s length must be between 15 – 50 characters.
• After that the player will be back to the design menu.
Halaman : 15 dari 17
Page 15 of 17
2.3 Remove
• If the player chooses remove menu, then the bot will display all item in the chosen room.
After that the bot will prompt the user to insert item’s name.
• Validate the input must be item in the room and exist.
• Validate the item player wanted to delete is not a treasure.
• Validate the item player wanted to delete is not a container and not a default item.
• Validate the item player wanted to delete is not required by another item
• After that the bot will prompt the user whether to modify other items or not. Validate the
input must be yes or no (Case Insensitive).
Halaman : 16 dari 17
Page 16 of 17
• If the player choose no, then the player will be prompt again to choose whether to add,
update, or remove item.
• If the player choose yes, then proceed to the next step. Because the player modify the item
in the room, he/she might want to change the description of the room. Therefore, the bot
will prompt the player to input whether to update the room’s description or not. Validate the
input must be yes or no (Case Insensitive).
• If the player chooses yes, then the bot will prompt the user to input new description of the
room. Validate the new description’s length must be between 15 – 50 characters.
• After that the player will be back to the design menu.
3. Exit
If the exit menu is chosen, all item data will be saved to ‘[Link]’ and all room data will be saved to
‘[Link]’ the program will terminate.
Please run the EXE file to see the sample program.
Halaman : 17 dari 17
Page 17 of 17