コード例 #1
0
        private void nFLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FootballTeamGenerator teamGenerator = (FootballTeamGenerator)parseFile(Sports.Football);

            if (teamGenerator == null)
            {
                return;
            }

            NFLChooseForm form = new NFLChooseForm(teamGenerator.getAllPlayers(), Convert.ToInt32(salaryCapTextBox.Text), Convert.ToInt32(salaryThresholdTextBox.Text));

            form.Show();
        }
コード例 #2
0
ファイル: Main Form.cs プロジェクト: sphillips9/Draft-Winners
        private GenerateTeams parseFile(Sports league)
        {
            startTime();

            workingProgressLabel.Text = "Starting Calculations";
            GenerateTeams teamGenerator;
            int salaryCap = Convert.ToInt32(salaryCapTextBox.Text);
            int threshold = Convert.ToInt32(salaryThresholdTextBox.Text);

            if (league == Sports.Football)
            {
                teamGenerator = new FootballTeamGenerator(salaryCap, threshold);
            }
            else if (league == Sports.Hockey) {
                teamGenerator = new NHLTeamGenerator(salaryCap, threshold);
            }
            else if (league == Sports.Basketball)
            {
                teamGenerator = new BasketballTeamGenerator(salaryCap, threshold);
            }
            else if (league == Sports.Golf)
            {
                teamGenerator = new GolfTeamGenerator(salaryCap, threshold);
            }
            else
            {
                throw new NotImplementedException();
            }

            OpenFileDialog file = new OpenFileDialog();
            file.Multiselect = false;

            if (file.ShowDialog() == DialogResult.OK)
            {
                Console.WriteLine(file.FileName);
                var reader = new StreamReader(File.OpenRead(file.FileName));

                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    String[] values = line.Split(',');
                    for (int i = 0; i < values.Length; i++)
                    {
                        values[i] = values[i].Replace("\"", String.Empty);
                    }

                    Player.Positions pos = Player.convertToEnum(values[0]);
                    if (pos == Player.Positions.INVALID)
                    {
                        continue;
                    }

                    int salary;
                    Int32.TryParse(values[2], out salary);
                    double points;
                    Double.TryParse(values[4], out points);

                    Player player = new Player(pos, values[1], uniqueID++, salary, points);
                    teamGenerator.addPlayer(player);
                }
                reader.Close();
                return teamGenerator;
            }

            return null;
        }
コード例 #3
0
        private void openCollegeFootballTeamCalculator(object sender, EventArgs e)
        {
            FootballTeamGenerator teamGenerator = (FootballTeamGenerator)parseFile(Sports.Football);

            launchTeamGenerationThread(teamGenerator, GenerateTeams.League.College);
        }
コード例 #4
0
        private GenerateTeams parseFile(Sports league)
        {
            startTime();

            workingProgressLabel.Text = "Starting Calculations";
            GenerateTeams teamGenerator;
            int           salaryCap = Convert.ToInt32(salaryCapTextBox.Text);
            int           threshold = Convert.ToInt32(salaryThresholdTextBox.Text);

            if (league == Sports.Football)
            {
                teamGenerator = new FootballTeamGenerator(salaryCap, threshold);
            }
            else if (league == Sports.Hockey)
            {
                teamGenerator = new NHLTeamGenerator(salaryCap, threshold);
            }
            else if (league == Sports.Basketball)
            {
                teamGenerator = new BasketballTeamGenerator(salaryCap, threshold);
            }
            else if (league == Sports.Golf)
            {
                teamGenerator = new GolfTeamGenerator(salaryCap, threshold);
            }
            else
            {
                throw new NotImplementedException();
            }

            OpenFileDialog file = new OpenFileDialog();

            file.Multiselect = false;

            if (file.ShowDialog() == DialogResult.OK)
            {
                Console.WriteLine(file.FileName);
                var reader = new StreamReader(File.OpenRead(file.FileName));

                while (!reader.EndOfStream)
                {
                    var      line   = reader.ReadLine();
                    String[] values = line.Split(',');
                    for (int i = 0; i < values.Length; i++)
                    {
                        values[i] = values[i].Replace("\"", String.Empty);
                    }


                    Player.Positions pos = Player.convertToEnum(values[0]);
                    if (pos == Player.Positions.INVALID)
                    {
                        continue;
                    }

                    int salary;
                    Int32.TryParse(values[5], out salary);
                    double points;
                    Double.TryParse(values[8], out points);

                    Player player = new Player(pos, values[2], uniqueID++, salary, points);
                    teamGenerator.addPlayer(player);
                }
                reader.Close();
                return(teamGenerator);
            }

            return(null);
        }