Create a method to dump the data to the screen
The method
The following method will cycle through each Character, Place and Item and display all of the data for each:
private static void DumpData(List<Character> characters, List<Item> items, List<Place> places)
{
foreach(Character C in characters)
{
Console.Write(C.ID +" ");
Console.Write(C.Name + " ");
Console.Write(C.Description + " ");
Console.WriteLine(C.CurrentLocation);
}
foreach(Place P in places)
{
Console.Write(P.id + " ");
Console.Write(P.Description + " ");
Console.Write(P.North + " ");
Console.Write(P.East + " ");
Console.Write(P.South + " ");
Console.Write(P.West + " ");
Console.Write(P.Up + " ");
Console.WriteLine(P.Down);
}
foreach(Item I in items)
{
Console.Write(I.ID + " ");
Console.Write(I.Description + " ");
Console.Write(I.Status + " ");
Console.Write(I.Location+ " ");
Console.Write(I.Name + " ");
Console.Write(I.Commands + " ");
Console.WriteLine(I.Results);
}
}
Using the Method
Add this code as a method into your program. Now we need to run it so in main method so change:
if (LoadGame(filename, characters, items, places))
{
PlayGame(characters, items, places);
}
to add the extra code before PlayGame is called:
if (LoadGame(filename, characters, items, places))
{
Console.WriteLine("Do you want to dump the data??");
string choice = Console.ReadLine();
if (choice == "yes")
DumpData(characters, items, places);
PlayGame(characters, items, places);
}