Design your own text-based adventure game

Assignment Help Programming Languages
Reference no: EM131990499

Assignment -

Part I:

Written Exercise 1: Imagine you would like to allow rooms to have a new type of exit (e.g. "up"). Identify each class and method that you would have to change in order to allow for this type of exit. Briefly describe the changes you would make in each class and method that you identified. NOTE: Do not actually make these changes yet!

Several methods in the Game class contain repeated functionality. Specifically, the print Welcome method and the go Room methods both print a description of the current room and a list of the exits. As we have learned, having the same functionality implemented in multiple locations can lead to the introduction of errors when software is modified. Correct this problem by factoring the common functionality out of these methods into a method of its own. Then call this new method each place the description and exits are to be displayed.

Part II:

Currently the code that generates and displays the list of exits from a room is contained in the Game class. This is not a particularly good design. Each room in the game is represented by a Room object. The Room object contains fields that store the information about that room's exits. Therefore it should seem like this program would be better if the code to generate a list of the exits for a room would be contained in the Room class. Make this improvement by adding a method named getExitString to the Room class. This method should return a String listing the exits from the room. For example, if the room has exits to the north and west, this method should return a String containing: "north west".

Now that each Room is capable of generating a list of its own exits. Refactor the code in the Game class to take advantage of this functionality. I.e. anywhere the Game class generates a list of the exits from the current room, change it to use your getExitString method.

Written Exercise 2: After making the above improvements to the code, imagine again that you would like to allow rooms to have a new type of exit (e.g. "up"). Now identify each class and method that you would have to change in order to add the new type of exit. Has the design improved? Why or why not? NOTE: Do not actually make these changes at this stage!

Currently, the Game class generates the full description of the current room (including information about exits) and displays it. This is dealing with data of the Room class, so the Room class should be responsible for generating this description. Add a method called getLongDescription to the Room class that returns a String containing the description and exits of a room, and refactor the Game class to use it whenever the Game needs to print information about a Room.

Part III:

Design your own text-based adventure game, using the given zuul game as a starting point. Some possible game scenarios are described in Exercise 6.3 of the text and you will have others from your brainstorming activity. If you find it difficult to visualize this sort of game scenario, try modeling your game on some familiar real-world location. If you need additional inspiration, you can try playing the original Colossal Cave Adventure game.

Some additional specifications:

  • Your game scenario must include at least six different rooms.
  • There must be at least six types of exits for the rooms in your game. For example, you could use north, south, east, west, up and down. This requirement does NOT mean that each room must have 6 exits -- most or even all rooms will have fewer.
  • Your game scenario must include at least four items that the player could find, pick up and potentially use.
  • Your game must have some way for the player to win. Most likely, this will be by achieving some goal such as finding a particular item, surviving for some specified number of moves, ... whatever makes sense for your game.

Written Exercise 3: Write a brief description of your game, including the setting for the game, the items in the game, and how a player wins. Save this in a Word doc to be submitted with your assignment.

Written Exercise 4: Draw a map for your game scenario. Label the rooms and the exits (connections between rooms), and specify the locations of the items. The map can be hand-drawn - you do not need to use a drawing program. This map must also be placed in the Word doc. Update the comments at the beginning of the Game class and the message displayed by the printWelcome method so that they describe your game.

Change the createRoomsAndPlayer method in the Game class so that it creates the rooms and exits that you invented for your game. You do not need to add any items to your game yet. You will add items later.

Update the test methods in the GameTest class as necessary to account for your changes to the Game class. You can directly edit the code in the test class, or delete any test methods that do not pass and re-record them. Play the game for a bit - enjoy the fruits of your hard work!

Part IV:

In many games (perhaps even in yours) there may be a very large number of different types of exits (e.g. "up", "down", "window", "slide", "stairway", "trapdoor", "trampoline", "fire-pole" etc...) One way to support such exits would be to make the changes that you identified in Written Exercise 2 for each imaginable type of exit. This is clearly better than it would have been before you completed Part II, but it is still not ideal. It would be better if it were possible for an exit to have any arbitrary name and that when given the name of an exit we could find the associated Room that lies beyond. This should sound like a good job for a HashMap where the name of an exit is the key and the Room lying beyond the exit is the value. Improve the design of the Room class by refactoring it so that it uses a HashMap to store the exits instead of an individual field for each exit.

Play the game to check that it still works - take a deep breath and relax a bit!

Part V:

You game scenario requires that there be items positioned throughout the world that the player can pick up and possibly use. An item sounds like something that should be represented by an object! So create an Item class to represent the items in your game. You will need to decide what fields your Item class needs to have, what parameters the constructor will require and what methods the class will have. At a minimum, items will have a name and a description. However, items may have any other attributes that make sense for your game (e.g. weight, colour, value, destructive power ..)

Now that there is a class for representing Items we need a way to allow the rooms to contain an item. Modify the Room class so that one item can be added to or removed from the room. You will need to think about what fields and methods to add to the Room class. Also think about what the methods that you add should do when an attempt is made to add an item to a room that already contains an item, or an attempt is made to remove an item from a room that does not contain an item.

Now that a room can contain an item, when the player enters a room he/she should be told about the item in that room (if there is one). Modify the appropriate code so that if the player enters a room containing an item, the name and description of the item are displayed along with the description of the room and the list of exits.

Edit the code in the Game class so that the items for your game are created and added to the appropriate rooms at the start of the game. Recall that your game must include at least four items. Be sure to test any methods that you add or modify. Play the game to ensure that your items are appearing in the rooms - enjoy the coolness of what you are creating!

Part VI:

Now that rooms can contain items and a player will know when they enter a room with an item, it would be nice if the player could pick up and carry items. Add functionality to the Player class that will allow the player to pick up and drop items. The player should be able to carry any number (i.e. a collection) of items.

Update your tests for the Player class to test the addition and removal of items.

Modify the Game class so that it will recognize the command take. When the user enters the "take" command, the item in the current room, if there is one, should be added to the items that the player is carrying and a message should be printed indicating that the player has taken the item. If there is no item in the current room the take command should print an error message. Be sure to test any methods that you add or modify. (Hint: Remember that one task of the Game constructor is to "teach" the CommandReader what words are valid commands. Thus, you will need to make a change in Game's constructor if you want to introduce a new command.)

Play the game to be sure the take command works!

Modify the Game class so that it will recognize the command inventory. When the user types "inventory" the game prints the names of the items that the player is currently carrying. You should think carefully about where the list of item names should be generated. (Consider the fact that the player is carrying the items, and think about how the list of exits for a room is generated and displayed.)

Play the game to be sure the inventory command works!

Add support to the game for a drop command so that the player can drop an item by name (e.g. "drop book"). The dropped item should appear in the current room. If the current room already contains an item, the drop command should print an error message indicating that the room is full and the player should continue to carry the item.

Play the game to be sure the drop command works!

Notice that when you use the help command take, inventory and drop do not appear as command words. Modify the printHelp method of the Game class so that it automatically displays any new command words that are added to the game. Hint: there is a helpful method in the CommandReader class.

Play the game to be sure the modified help command works - celebrate!

THIS IS END OF THE REQUIRED PART OF THE ASSIGNMENT. Below are bonus enhancements:

If you completed all of the above parts, you may complete any or all of the following exercises for extra credit. You must explicitly state which (if any) of these bonus problems you have done.

Include a description of the bonus exercises that you have completed with the written exercises.

Your test cases for character movement do not need to check the location of the character after moving (because characters may move randomly).

Variable bonus points:

if some other game modification or extension makes more sense for your game scenario, you may make this modification or extension for extra credit with approval of your tutor. You must also thoroughly describe this modification or extension in your written game description.

Workshop activities

Your workshop activity this week is to start work on your.

Attachment:- Assignment File.rar

Reference no: EM131990499

Questions Cloud

Describe three to five driving forces that led to civil war : Describe three to five driving forces that led to the Civil War. State your thesis on the significance of this slavery issue, as exemplified in your research.
Analyze the key e-marketing issues : Analyze the e-business strategy the company has formulate and implemented to face the identified issues (keep in mind that issues might also be opportunities
Create a class named cellphone which will represent the code : Create a class named CellPhone which will represent the code to manage a cell phone's operating system.
Analyze the implications of each issue : Describe and analyze the implications of each issue, including who or what were affected by the company's response. In identifying issues and addressing.
Design your own text-based adventure game : Design your own text-based adventure game, using the given zuul game as a starting point. Write a brief description of your game, including setting for game
Discuss the basics of strategic planning : This course features a debate component within the Discussion Boards. To prepare for the debate topic within this course, view a video that reviews.
Describe the acquisition process in the it industry : This is just for the one server blade. Storage devices such as tape drives, tapes, storage for the tapes, racks, environmental controls, security controls.
Describe the administration of franklin roosevelt : Describe the most important developments in American foreign policy during the twentieth century. Describe the administration of Franklin Roosevelt.
What historical figures are incorporated into the film : What is the context of the film? What historical period and what historical figures are incorporated into the film? Summarize the plot of the film.

Reviews

len1990499

5/21/2018 3:10:35 AM

How much you will charge for this assignment? No word limit coz it is coding. Due date is 24th. Problems worth at most 2 extra points: Exercise 6.41 in the text. Exercise 6.42 in the text. Problems worth at most 4 extra points: Exercise 6.23 in the text. Exercise 6.43 in the text. Exercise 6.44 in the text. Exercise 6.45 in the text. Allow each room to contain a collection of items (rather than just one).

len1990499

5/21/2018 3:10:28 AM

Modify the game so that only a list of the names of the items in a room are displayed when the player enters. Then add a look command that allows the player to look at an item in the current room by name. For example, if the player types look book and there is an item named "book" in the current room, your game should display the description of that item. If there is no such item, your game should display an error message. If the player enters the look command with no second word, it should display the entire description of the room, its exits and the names of any items again.

len1990499

5/21/2018 3:10:21 AM

Problems worth at most 6 extra points: Exercise 6.26 in the text. Exercise 6.47 in the text. Modify your game to allow the player to win (as you described in your game scenario). Problems worth at most 8 extra points: Do Exercise 6.48 in the text. Note that you must do Exercise 6.47 before doing this one. Hints: You can add the following method to the Room class to randomly choose an exit for the character when it moves. Note that exits is the field (of type HashMap) that contains the exits for the room - if you used a different field name, use that name instead.

Write a Review

Programming Languages Questions & Answers

  Design application that plays a guessing game with numbers

Design and implement an application that plays a guessing game with numbers. The program should generate a random number between 1 and 100 (inclusive), then repeatedly prompt the user to guess the number

  Read each line and create one complex object

Write all complex objects to file complexObj.txt and compute sum of all objects and append the object to the end of complexObj.txt

  Produce a store procedure to accept parameters

Produce a store procedure named spBalanceRange which accepts three optional parameters. Procedure returns the result set consisting of VendorName,

  Op-codes-add microcode to overlapping address ranges

Bmov a,b,n. This Block Move instruction moves n bytes of data from location a in memory to location b. Deal correctly with case of overlapping address ranges.

  Complete the function function has three parameters

Complete the function: func in the following program. This function has three parameters: The first and second parameters are of type: int. The third one is a function that has two parameters of type: int and returns a value of type: int.

  Create a multi-threaded competition

Create a multi-threaded competition in which opposing Robin Hoods will attack one another and try to take each other's gold coins.

  Writing static program analyses using LLVM

Dataflow Analysis. Objective - This assignment will familiarize you with writing static program analyses using LLVM

  Write program to read data for employee and print name

Write a program which reads data for employee and prints name and salary of employee. Data read is: Name. Number of hours worked.

  What will the permissions string contain

If you execute ls -ld on the project38" directory, what will the permissions string contain? If you execute ls -l on the iapp_v_8 file contained in project38 , what will the permissions string contain

  Write the constructor function makestk

Write the constructor function makestk, predicate function emptystk and mutator functions pushstk and popstk

  List three challenges in planning and designing

List three challenges in planning and designing a solution for a programming problem. What could you do to overcome these challenges?

  Write a program to compute the diameter of a steel rod

Write a program to compute the diameter in centimeters of a steel rod, an aluminum rod, and copper rod, which can withstand a particular compression load

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd