Map class assignment

From WLCS
Revision as of 10:39, 7 May 2010 by Admin (talk | contribs)

Objective

  • You will learn to create a class that makes use of Vectors and two-dimensional (2D) arrays

Purpose

  • The purpose of this class is to encapsulate all the attributes and methods of the entire maze. The Map class represents a grid of rooms, each connected to one or more of its neighbors. The grid will be represented as a two-dimensional array of Room objects; you will use loops to initialize each of the rooms in the array to contain a random description and, with some probability, a random monster and a random weapon.

Resources

Attributes

  • Your Map class should use the following attribute variables:
  • Room rooms[][]: a two-dimensional array of Room objects. The user will not need to manipulate this array directly, so this should be private and does not need accessor/mutator methods.
  • boolean visited[][]: a two-dimensional array of boolean variables. This array is used by the algorithm to generate a maze, described in the connectMaze() method below. The values should all be set to false, which Java will do by default - you do not need to include code for this purpose. Note that this method has nothing to do with whether the player has visited the room -- it is only used in the maze generation algorithm, below.
  • int height: the number of rows in the grid represented by the rooms[][] array. Because this is set when the Map is created and cannot be changed, you should provide an accessor (i.e. getHeight()) but no mutator.
  • int width: the number of columns in the grid represented by the rooms[][] array. Again, you should provide an accessor but not a mutator.
  • int maxMonsterStrength, maxMonsterSkill, maxMonsterHitPoints, maxMonsterArmorClass: the maximum strength, skill, hit points, and armor class of a monster in the Map, all with a default value of 20. You must provide accessor and mutator methods for each of these variables.
  • int maxWeaponDamageMod: the maximum damage modifier of a weapon in the map, with a default value of 5. You must provide accessor and mutator methods for this as well.
  • Descriptions desc = new Descriptions(): this object will be used in the constructor, below. Note that it should not be static.
  • Random rand = new Random(): this will be used to generate random numbers throughout the Map class code.

Methods