Beispiel #1
0
        private int AdditinalTempScore(Player p, int i, int tempAddHandicap, Course course)
        {
            int tempScore = (((course.holes[i].par + tempAddHandicap) - p.card.scores[i]) + 2);

            if (tempScore < 0 || p.card.scores[i] == 0)
            {
                return 0;
            }

            return tempScore;
        }
Beispiel #2
0
        private void CalculateFinalScoreStableFordBrutto(Player p, Course course)
        {
            p.CalcualteAdditionalHandicapeForStableFordNetto();
            for (int i = 0; i < LENGTH_OF_COURSE; i++)
            {
                int tempAddHandicap = 0;

                int tempScore = AdditinalTempScore(p, i, tempAddHandicap, course);

                p.finalScoreStableFordBrutto = p.finalScoreStableFordBrutto + tempScore;
            }
        }
Beispiel #3
0
        private static void Init(Course course)
        {
            for (int i = 1; i < 18 + 1; i++)
            {
                course.AddHole(new Hole()
                {
                    hardness = i,
                    number = i,
                    par = 3
                });
            }

            course.PrintHoles();
        }
Beispiel #4
0
        public Returns Go(Course course, List<Player> players)
        {
            PrintPlayer(players);

            CalculatePlayerPoints(course, players);

            Returns ret = new Returns();

            ret.standsStrokeplayNetto = players.OrderBy(x => x.FinalScoreStrokePlaynetto).ToArray();
            ret.standsStrokeplayBrutto = players.OrderBy(x => x.FinalScoreStrokePlayBrutto).ToArray();
            ret.standsStablefordNetto = players.OrderByDescending(x => x.finalScoreStableFordNetto).ToArray();
            ret.standsStablefordBrutto = players.OrderByDescending(x => x.finalScoreStableFordBrutto).ToArray();

            return ret;
        }
Beispiel #5
0
        private void CalculateFinalScoreStableFordNetto(Player p, Course course)
        {
            p.CalcualteAdditionalHandicapeForStableFordNetto();
            for (int i = 0; i < LENGTH_OF_COURSE; i++)
            {
                int tempAddHandicap = 0;
                tempAddHandicap = p.additinalHandicap.additinalForAll;
                if (course.holes[i].hardness <= p.additinalHandicap.amountOfAdditianlHoles)
                {
                    tempAddHandicap = tempAddHandicap + 1;
                }

                int tempScore = AdditinalTempScore(p, i, tempAddHandicap, course);

                p.finalScoreStableFordNetto = p.finalScoreStableFordNetto + tempScore;
            }
        }
Beispiel #6
0
        private void Button_Click(object sender, EventArgs e)
        {
            string path = "";
            DialogResult fileToOpenDialog = openFileDialog1.ShowDialog();
            if (fileToOpenDialog == DialogResult.OK) // Test result.
            {
                path = openFileDialog1.FileName;
            }

            textBox1.Text = path;

            List<Player> players = new List<Player>();

            string pathToExcelFile = textBox1.Text;
            string sheetName = "Arkusz1";
            var excelFile = new ExcelQueryFactory(pathToExcelFile);
            var playersInExcel = from a in excelFile.Worksheet(sheetName) select a;

            foreach (var a in playersInExcel)
            {
                players.Add(
                    new Player()
                    {
                        name = a["Name"],
                        handicap = Convert.ToInt32(a["handicap"]),
                        card = new Card()
                        {
                            scores = new int[] { Convert.ToInt32(a["h1"]), Convert.ToInt32(a["h2"]), Convert.ToInt32(a["h3"]), Convert.ToInt32(a["h4"]), Convert.ToInt32(a["h5"]), Convert.ToInt32(a["h6"]), Convert.ToInt32(a["h7"]), Convert.ToInt32(a["h8"]), Convert.ToInt32(a["h9"]), Convert.ToInt32(a["h10"]), Convert.ToInt32(a["h11"]), Convert.ToInt32(a["h12"]), Convert.ToInt32(a["h13"]), Convert.ToInt32(a["h14"]), Convert.ToInt32(a["h15"]), Convert.ToInt32(a["h16"]), Convert.ToInt32(a["h17"]), Convert.ToInt32(a["h18"]) }
                        }
                    }
                    );
            }

            Course course = new Course();

            Init(course);

            var prog = new Calculate();
            result = prog.Go(course, players);
        }
Beispiel #7
0
 private void CalculatePlayerPoints(Course course, List<Player> players)
 {
     foreach (Player p in players)
     {
         CalculateFinalScoreStrokePlayeBrutto(p);
         CalculateFinalScoreStrokePlayeNetto(p);
         CalculateFinalScoreStableFordNetto(p, course);
         CalculateFinalScoreStableFordBrutto(p, course);
     }
 }