Exemplo n.º 1
0
 // play method of adapter which calls the playmethod of each type's class
 public void Play(Game game)
 {
     if (game.Get_Type() == Game.GameTypes.NintendoSwitch)
     {
         advancedConsolePlayer.PlayNintendo(game);
     }
     else if (game.Get_Type() == Game.GameTypes.PS4)
     {
         advancedConsolePlayer.PlayPS4(game);
     }
     else if (game.Get_Type() == Game.GameTypes.XBox)
     {
         advancedConsolePlayer.PlayXbox(game);
     }
 }
        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.");
        }