コード例 #1
0
        public void PrepareTeam(string teamOne, string teamTwo, int teamSize)
        {
            this.TeamOne  = teamOne;
            this.TeamTwo  = teamTwo;
            this.TeamSize = teamSize;

            Random rnd = new Random();

            while (teamSize > 0)
            {
                int next = rnd.Next(1, 3);
                teamOneFighters.Add(fighterFactory.CreateFighter(next, teamOne));
                next = rnd.Next(1, 3);
                teamTwoFighters.Add(fighterFactory.CreateFighter(next, teamTwo));
                teamSize--;
            }

            Console.WriteLine("Team Details :");
            Console.WriteLine(TeamOne);
            Console.WriteLine(string.Join(',', teamOneFighters.Select(f => f.Name)));
            Console.WriteLine(TeamTwo);
            Console.WriteLine(string.Join(',', teamTwoFighters.Select(f => f.Name)));
        }
コード例 #2
0
        public string ManufactureFighter(string name, double attackPoints, double defensePoints)
        {
            if (machines.Any(x => x.Name.Equals(name)))
            {
                return(string.Format(OutputMessages.MachineExists, name));
            }

            var currentFighter = fighterFactory.CreateFighter(name, attackPoints, defensePoints);

            machines.Add(currentFighter);
            return(string.Format(OutputMessages.FighterManufactured
                                 , name
                                 , currentFighter.AttackPoints
                                 , currentFighter.DefensePoints
                                 , currentFighter.AggressiveMode ? "ON" : "OFF"));
        }