FINAL
PROGRAMMING
PROJECT
The design is due at the beginning of lab on Thursday of eighth week.
The implementation is due at the beginning of class on Friday of tenth week.
You may work on this programming project in pairs, if you wish. If you work with someone else, be sure that both of you understand the work that gets done. As before, it is also okay to get help from your friends, the TAs, and/or the instructor if you get stuck, but you should try to do it on your own first. Keep in mind that the goal is not just getting the program to work but learning how to write programs yourself; outside help will not be available to you during the exams. Also remember that you may not work with the same person on more than two of the programming projects for this course.
For this project you will implement a simulation of a simple, imaginary building. The building will contain at least four different rooms. You should place at least three people in the building; one will be controlled by the user, and the others will be controlled by the computer. You should also place some objects in the rooms.
A person can move from the room that he or she is in to any room with a connecting doorway. Your building should not have all of its rooms directly connected, but it should be possible to eventually reach any room from any other. For example, you might have a building with the following floor plan:
Here you can move from the Dining Room to either the Kitchen or the Hall, and from the Hall you can also reach the Study.+-------------+------+-------+ | | | | | Kitchen | | | | | | | +----- -----+ Hall | Study | | | | | | Dining Room | | | | | +-------------+------+-------+
A person should also be able to pick up objects that are in the room with him/her and to set down objects that he/she is carrying. However, a person should be able to carry at most two things at once.
Your program should offer the user a menu of commands (in a manner similar to the SodaMachine program). The commands should include at least the following:
Your program should alternate through the people in the simulated building. When it is the user's turn, the user selects a command from the menu. When it is another (simulated) person's turn, the computer should make a random choice to have that person pick something up, set something down, or move.
An interaction with your program might look something like this:
Select a command from the following menu: L - Look around I - Take inventory P - Pick up an object S - Set down an object M - Move C - Show menu of commands Q - Quit > l You are in the Dining Room. There are doors in the following directions: north east The room contains the following objects: candlestick > i You are carrying the following objects: programming project > m Which direction do you want to move? 1 - north 2 - east > 2 You are in the Hall. There are doors in the following directions: east west The following people are also in the room: Professor Plum The room contains the following objects: key > s Which object do you want to set down? 1 - programming project > 1 > m Which direction do you want to move? 1 - east 2 - west > 1 You are in the Study. There are doors in the following directions: west The room contains the following objects: book rope >
There is a lot of flexibility and room for creativity in this assignment, so have fun with it!
Optional features:
Here are a couple of extra things that you might try if you have time:
Professor Plum sets down a lead pipe. > s Which object do you want to set down? 1 - programming project > 1 Professor Plum picks up a programming project. > i You are not carrying anything. Professor Plum leaves the Hall. >
You are in the Dining Room. There are doors in the following directions: ahead right The room contains the following objects: candlestick > m Which direction do you want to move? 1 - ahead 2 - right > 2 You are in the Hall. There are doors in the following directions: ahead behind The following people are also in the room: Professor Plum The room contains the following objects: key
> m Which direction do you want to move? 1 - east 2 - west > 1 The door is locked. You cannot move through it unless you have a key. > p What do you want to pick up? 1 - key 2 - lead pipe > 1 > m Which direction do you want to move? 1 - east 2 - west > 1 You are in the Study. There are doors in the following directions: west The room contains the following objects: book rope >These extras do not carry any credit towards your grade on the project and are totally optional - just do them for the fun of it! (After you have completed all required work, of course.)
What to turn in:
The project design is due at the beginning of lab on Thursday of eighth week. You should hand in:
Display and Timer classes I handed out in class
during the first week.)
The implementation is due at the beginning of class on Friday of tenth week. You should hand in: