//constructor which instantiates the correct type class of advancedconsoleplayer public ConsolePlayerAdapter(Game.GameTypes gameType) { if (gameType == Game.GameTypes.NintendoSwitch) { advancedConsolePlayer = new NintendoPlayer(); } else if (gameType == Game.GameTypes.PS4) { advancedConsolePlayer = new PS4Player(); } else if (gameType == Game.GameTypes.XBox) { advancedConsolePlayer = new XboxPlayer(); } }
public void PlayGame(Game game) { Game.GameTypes type = game.Get_Type(); // built in PC support if (type == Game.GameTypes.PC) { Console.WriteLine("Playing " + game.Title + " on PC."); return; } //UNCOMMENT THIS FOR DEMO // adapter provides support for simulating playing on other platforms if (type == Game.GameTypes.NintendoSwitch || type == Game.GameTypes.PS4 || type == Game.GameTypes.XBox) { consolePlayerAdapter = new ConsolePlayerAdapter(type); consolePlayerAdapter.Play(game); return; } Console.WriteLine("Invalid game type " + game.Get_Type() + " not supported."); }