HTW Berlin Medieninformatik HTW Berlin
Fachbereich 4
Internationaler Studiengang
Internationale Medieninformatik (Bachelor)
Info 1: Informatik I
Winter Term 2022/23

Laboratory 11 : Keeping Track of Stuff

Pre-lab

This week's lab work will continue a larger project that will occupy us until the end of the semester.

What to Bring to Lab

Please bring these exercises printed out or written out with you to lab. Please have your name on your page.

P1. What items could be kept in the locations in your game? Come up with a list of at least 10 items. How heavy is each item?

P2. What will the starting position of the items be? List which items are going to be in which place.

Post-Lab, AKA  What To Turn In

Your completed assignment, submitted in Moodle as a pdf, should include:

Assignment

Adding Items

  1. Start with your game by exchanging your game from the last exercise and the items specified in the pre-lab with another group (or this refactored version of Zuul if you are working from home on an excuse you cleared with your lab instructor before the lab). Read through the code and documentation and see if you can understand what the game is about. Write a short description in your report. Is there anything that needs better explanation? Do you understand what the items are to be? Speak with the authors to make sure you understand.
  2. Extend that project so that a room can contain a single item. Items have descriptions and weights. When creating rooms and setting their exits, items for this game should also be created. When a player enters a room, information about an item present in this room should be displayed.
  3. How should the information about an item present in a room be produced? Which class should produce the string describing the item? Which class should print it? Why? If answering this exercise makes you feel you should change your implementation, go ahead and do so – and explain in your report why.
  4. Modify the project so that a room can hold any number of items. Use a collection to do this! Make sure the room has an addItem method that places an item into the room. Make sure all items get shown when a player enters a room. Set up a fixture to thoroughly test this!
  5. Implement a "back" command that does not have a second word and takes the player back into the previous location. Test this! What happens if a second word is given?
  6. (For the bored) What happens if you type "back" twice? Is this behavior sensible? Implement it so that using it repeatedly takes you back several rooms, all to the beginning of the game if used often enough. Use a Stack data structure, even if we don't know about them yet. You can read about them in the API.

Writeup

Submit your writeup as your post-lab to the Moodle area by 22.00 the day before the next lab.

 


Copyright Prof. Dr. Debora Weber-Wulff
Questions or comments: <weberwu@htw-berlin.de>
Some rights reserved. CC-BY-NC-SA - Copyright and Warranty

The exercises are adapted from Objects First with Java, A Practical Introduction Using BlueJ. David Barnes & Michael Kölling, 2016