Difference between revisions of "Implement a way to display your inventory"
(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...") |
(No difference)
|
Revision as of 08:37, 11 December 2018
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;