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...") |
|||
Line 1: | Line 1: | ||
+ | You can see what items you have in your inventory by typing "examine inventory". You could also add a command: | ||
+ | |||
=Easy Way= | =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: | 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: |
Latest revision as of 12:36, 11 December 2018
You can see what items you have in your inventory by typing "examine inventory". You could also add a command:
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;