本文整理汇总了C#中Team.PlayGame方法的典型用法代码示例。如果您正苦于以下问题:C# Team.PlayGame方法的具体用法?C# Team.PlayGame怎么用?C# Team.PlayGame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Team
的用法示例。
在下文中一共展示了Team.PlayGame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Strategy
/// <summary>
/// 【策略模式】
///
/// 球队与球队策略(Team and TeamStrategy)在比赛中,终端用户可以改变球队的策略(如从进攻改为防守)
/// </summary>
static void Strategy()
{
////'Let us create a team and set its strategy,
// //'and make the teams play the game
////'Create few strategies
var attack = new AttackStrategy();
var defend = new DefendStrategy();
////'Create our teams
var france = new Team("France");
var italy = new Team("Italy");
System.Console.WriteLine("Setting the strategies..");
////'Now let us set the strategies
france.SetStrategy(attack);
italy.SetStrategy(defend);
// //'Make the teams start the play
france.PlayGame();
italy.PlayGame();
System.Console.WriteLine();
System.Console.WriteLine("Changing the strategies..");
// //'Let us change the strategies
france.SetStrategy(defend);
italy.SetStrategy(attack);
// //'Make them play again
france.PlayGame();
italy.PlayGame();
////'Wait for a key press
System.Console.Read();
}