4 Replies Latest reply on Nov 28, 2006 7:33 AM by JosAH

    One Dimensional Array.


      Declare and initialize a 20-element array. In each element place one of the following characters:
      �W� � Wizard
      �S� -- Sword
      �D� -- Demon
      �B� -- Blank � Save spot.

      Example an array can look like this:
      W S S D B D W B B D W S W D B D S W B S

      You ask the player to select a location in Hogarth Tower. (Choose a number from 0 � 19) That places the player at a position in the array. In the example if the user enters a 5 as a starting position (starting at 0). So, the entry at that position is a B (Blank).

      Based on the rules below the player can then move North (add 1 to the array index) or South (subtract 1 from the array index). Here are the rules:

      (1)     For each Blank (B) spot output the message �Safe Place�; 2 points is awarded.
      (2)     For each Wizard (W) spot output the message �You picked up a Wizard�; 3 Points is Awarded.
      (3)     For each Sword (S) spot output the message �You picked up a Sword�; 4 Points is awarded.
      (4)     For each Demon (D) encountered display the message �A demon has attacked�; subtract 5 points.

      The game is over when (a) the player types in 99 this ends the game. Print out the accumulated points. Or (b) when the points are below 0 � the player is killed. Display �You are killed� if the points garnered by the player is below zero.

      Make sure the player does not go beyond the array boundary. The boundary has is limited by the size of the array 19 elements.

      phew... so guyz can you answer this one? it's a little bit hard making this.. lol . hmm.. just use One dimensional array. Good Luck!

      Message was edited by: