Implement a way to display your inventory

From TRCCompSci - AQA Computer Science
Revision as of 08:37, 11 December 2018 by Admin (talk | contribs) (Created page with "=Easy Way= For some reason the skeleton program contains a method called DisplayInventory but this is never used within the program. Therefore the easiest way to implement thi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Easy Way

For some reason the skeleton program contains a method called DisplayInventory but this is never used within the program. Therefore the easiest way to implement this is to add a command into the switch case statement in play game:

instruction = GetInstruction();
Command = ExtractCommand(ref instruction);
switch (Command)
{
     case "get":
         GetItem(items, instruction, characters[0].CurrentLocation, ref stopGame);
         break;

Find the lines of code above and now add a new case similar to the code below (I have called mine "inventory"):

instruction = GetInstruction();
Command = ExtractCommand(ref instruction);
switch (Command)
{
     case "get":
         GetItem(items, instruction, characters[0].CurrentLocation, ref stopGame);
         break;
     case "inventory":
         DisplayInventory(items);
         break;