Beruflich Dokumente
Kultur Dokumente
(Group A)
Assignment 1
Direction:
Answer all of the following questions.
Submit your hard copy (source codes & sample output) and soft
copy (source codes) via the online learning system.
Assignment should be done individually
Date due:
19/04/2015; Sunday 12 Oclock midnight
Assignment 1
Question 1: Magic house tour
Write a program that will provide a tour in the magic house. Throughout
the tour do the following:
i. User can only enter the next place if it is linked to the current place
(refer the diagram below e.g. store is linked to front door and table is
linked to store
ii. Whenever user enter a new place, the program will print the place
where he is currently along with a short description of what the user can
see there.
iii. At any point user can choose to go back out by going to the front door
by entering back at the next move prompt. To do so, the user must go
through the correct path out that will bring him/her back to the front
door (e.g. if user is in room1 then the path out is 1. Up stair, 2. Front
door; if user is at window2, then the path out is either 1. Front door or 1.
Bathroom2, 2. room2, 3. Up stair, 4. Front door. (Notice that from under
bed, user can go to store and back to front door directly!)
iv. As long as the user enter the wrong path back user will keep finding
his/her way until the correct path is found.
v. If user reach one of the dead end place, (there are two in the
diagram), program will declare that he/she is sucked forever in the
house!
vi. Whenever the user enter exit as the next move without providing the
correct path back, he or she will be stuck forever in the house!
front
door
hunted room -
dead end
cupboard
table room1 room2
1
small
window1 store window2
room
front
door
roof top
dead end
Sample 2:
Welcome to the Magic house you are at front
door
Next move> upstairs
You are upstairs a nice place.
Next move> cupboard1
Wrong move: cupboard1 is unreachable from
store
Next move> table
Table: you reach the end, to go out, please
provide the way out
Next move> exit
You are lost forever in the house, good bye!
Drink:
Hot Chocolate RM 1.50
Ice Tea RM 1.00
Fresh Orange Juice RM 2.50
Food:
Egg Fried Rice RM 3.50
Chicken Fried Rice RM 3.50
Sultana Fried Rice RM 4.00
Special:
Tom Yum RM 3.50
Fried Chicken RM 3.00 piece
Fried Keli Fish RM 2.00 piece
Vegetable Soup RM 3.50
NOTE: To format the output as given above, you must use the
System.out.printf ( ) method.
Question 1:
Correct input & variables: 5marks
Correct selection structures: 7 marks
Correct looping structures: 4 marks
Proper output Format: 4 marks
Question 2:
Correct input & variables: 3 marks
Correct selection structures: 5 marks
Correct looping structures: 3 marks
Correct calculation: 4 marks
Proper Format of Output: 5 marks
Originality: 7 marks
Efficient / Creative solution 3 marks