CSC81002 Fundamentals of Programming Assignment

Assignment Help Programming Languages
Reference no: EM132448525

CSC81002 - Fundamentals of Programming - Southern Cross University

Specifications

Your task is to complete various exercises in BlueJ, using the Java language, and to submit these via the MySCU link created for this purpose.
Marking criteria includes:

• Use of correct coding style, including the use of comments;
• Accuracy of coding;
• Use of suitable coding structures;
• Correct submission and naming conventions of assessment items as required

Section 1:

Set up your assignment

To set up your assignment you will need to do the following:

• Create a folder called username-A2. For example, mine would be pchakrab15-A2.
• Copy the zuul-bad project in chapter 8 of the book projects to your username-A2 folder.
• Create a word document called username-A2-documentation. For example, mine would be pchakrab15-A2- documentation. Add your full name and student id to the footer. You will lose marks if you do not do this. Save this word document to your username-A2 folder.
After you have set up your assignment open the zuul-bad project In BlueJ, create a new instance of the Game class, run the play method and familiarize yourself with the game.
You should also:

• Review the code style guide in topic 7 as this is the style you will be required to use in your assignment.
• Download chapter 6 of the text book from topic 7 on mySCU as you will need this for the assignment.

Design your game

Using the given zuul game as a starting point, you must design your own game.

Some possible game scenarios are described in Exercise 6.3 of the text. If you find it difficult to visualize this sort of game scenario, try modelling your game on some familiar real-world location. If you need additional inspiration, you can try playing the original Colossal Cave Adventure game.

You must have the following in your game:

• Your game scenario must have at least seven (7) different rooms.
• Your game scenario must have at least seven (7) types of exits, between north, south, east, west, up, down, south-east and any other you require. This requirement does NOT mean that each room must have 7 exits.
• Your game scenario must include at least five (5) items that the player could find, pick up and use.
• Your game must have some way for the player to win (i.e., a winning condition). Most likely, this will be by achieving some goals such as finding a Sectionicular item,

surviving for some specified number of moves and so on, whatever makes sense for your game.

Written Exercise 1

Write a brief description of your game in your word document. You must:

• Describe your game including the back story and the setting
• List the items in the game
• Explain how the player wins

Written Exercise 2

Draw a map for your game scenario. You must:

• Label the rooms
• Label the exits (connections between rooms)
• Specify the locations of the items
The map can be hand-drawn. You do not need to use a drawing program but your map must be clearly readable. This map must also be placed in the Word doc.

Section 2:

Written Exercise 3

Your game has 7 exits however the zuul-bad game only has 4 exits. Your will also have more rooms than zuul-bad and they will have different names. Copy the following template into your word document and replace the text for each of the methods. You must identify and describe the changes you would need to make to the zuul-bad project to convert it into your game. You need to consider the additional exits and rooms you have in your game. DO NOT WRITE THE CODE AT THIS Section...YOU WILL NOT GET ANY MARKS, you must identify and describe the changes. Below template is an example of changes in the Room class, so you can see what is required.

Section 3:

Written Exercise 4

The printWelcome method and the goRoom methods contain code duplication and both print a description of the current room and a list of the exits. This is not a good design. Explain why.

Programming exercise 1

Correct the problem of repeated functionality in the printWelcome and goRoom methods by refactoring the repeated functionality out of these methods into a method of its own called getRoomExitsAndDescription. Then call this new method in each place the description and exits need to be displayed.

Written Exercise 5

In the previous exercise you created the getRoomExitsAndDescription method that prints a description of the current room and a list of the exits. This code is contained in the Game class. This is not a good design. Explain why.

Programming exercise 2

• Refactor the code that generates the list of the exits into a method named getExitString in the Room class. This method should return a String listing the exits from the room. For example, if the room has two exits and they are to the north and west, this method should return a String containing: "north west".
• Add a method called getLongDescription to the Room class that returns a String containing the description of the current room and a list of the exits of a room (hint: call the getExitString method you just created
• Now that each Room has a method that can print information about a Room refactor the code in the Game class to take advantage of this functionality. i.e. anywhere the

Game class uses the getRoomExitsAndDescription method, change it to use your getLongDescription method.

Written Exercise 6

Now that we have made some changes to our code create a template similar to the template I provided for written exercise 3 for the Game and Room class (note that it will be different as you now have new methods and have refactored code into different classes).
Then identify and describe the changes you would need to make to the zuul-bad project to convert it into your game, just like you did in written exercise 3. You need to consider the additional exits and rooms you have in your game.

Written Exercise 7

Answer the following question. Has the design improved? You must explain why or why not.

Programming exercise 3

• Update the comments at the beginning of the Game class, the Room class and the message displayed by the printWelcome method so that they describe your game.
• Update the Game and Room 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.

Section 4

Programming exercise 4

Even with the improvements we have made to our code there are a lot of places that need to be changed to add a new exit. 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.

Section 5

Programming exercise 5

Your 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 ..)

Programming exercise 6

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.

Programming exercise 7

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.

Programming exercise 8

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.

Section 6

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.

Programming exercise 9

Modify the Game class so that it will recognize the command pick. When the user enters the "pick" 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 picked up the item. If there is no item in the current room the pick 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 pick command works!

Programming exercise 10

Modify the Game class so that it will recognize the command record. When the user types "record" 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 list command works!

Programming exercise 11

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!

Programming exercise 12

Notice that when you use the help command the pick, record 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. Do not hard code the words in the printHelp method. Hint: you should modify the CommandWords class to do this.
Play the game to be sure the modified help command works - celebrate!

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

PLEASE NOTE YOU MUST:

• Allow each room to contain a collection of items (rather than just one).
• 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.

• 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.
/**
* choose a potential exit at random

*/
public String randomExit() {

Object [] dirs = exits.keySet().toArray();
int index = (int) (Math.random() * dirs.length); return (String) dirs[index];
}

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

Attachment:- Exercises in BlueJ.rar

Reference no: EM132448525

Questions Cloud

How the operating cycle for a merchandiser is different : Explain how the operating cycle for a merchandiser is different from a manufacturer. Explain the difference between perpetual and periodic inventory systems
Global teams-globalization strategy and economies of scale : Pick one of the following terms for your research: economies of scale, economies of scope, global companies, global teams, globalization strategy,
Discuss the mean for financial transactions : Write and Complete all Journal Entries, T-accounts, and the the Trial Balance.
Different strategies for entering the global market : You should consider the four different strategies for entering the global market. Explain what strategies these companies used when entering the global economy.
CSC81002 Fundamentals of Programming Assignment : CSC81002 Fundamentals of Programming Assignment Help and Solution, Southern Cross University - Assessment Writing Service
Define the corporation : Describe the researched corporation and industry being investigated. Provide background of the corporation and industry.
Mathematical calculation : You have just won the Strayer Lottery jackpot of $11,000,000. You will be paid in 26 equal annual installments beginning immediately.
Briefly describe the new initiative : Discuss new initiative or product, or it is introducing a change to technology or personnel that will affect your team and its daily working environment
Create a summary and correlation of stats for the dataset : Create a correlation of stats for the dataset. (provide a screen shot) (Hint: Transform may be needed). What is the Min, Max, Median, and Mean of the Price?

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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