Beispiel #1
0
 public static double Avg_Durchgang(Durchgang d)
 {
     if (d.GetAnzahlWürfe() == 0)
     {
         return(0);
     }
     return(d.GetDurchgangWert() / d.GetAnzahlWürfe());
 }
Beispiel #2
0
 /// <summary>
 /// speichert alle Würfe eines übergebenen Durchgangs in der DB
 /// </summary>
 /// <param name="d">Durchgang dessen Würfe gespeichert werden sollen</param>
 public static void SaveWürfeToDB(Durchgang d)
 {
     for (int y = 0; y < d.GetAnzahlWürfe(); y++)
     {
         DBConnect.InsertWurf(d.GetWürfe().ElementAt(y), d);
     }
 }
Beispiel #3
0
        public static void InsertDurchgang(Durchgang durchgang, Leg leg)
        {
            int finishBereich = 0;

            if (durchgang.IsFinishBereich())
            {
                finishBereich = 1;
            }

            string query = "INSERT INTO durchgang (`id_durchgang`, `id_leg`, `durchgangNummer`, `anzahlWurfe`, `finishBereich`) VALUES ('" + durchgang.GetId() + "', '" + leg.GetId() + "', '" + durchgang.GetDurchgangNummer() + "', '" + durchgang.GetAnzahlWürfe() + "', '" + finishBereich + "')";

            //open connection
            if (OpenConnection() == true)
            {
                try
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(query, connection);

                    //Execute command
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Durchgang: " + e.Message);
                    Console.ReadLine();
                }
                //close connection
                CloseConnection();
            }
        }
Beispiel #4
0
        public static int[] GetTrefferquoteDurchgang(Durchgang d, int feldMulti, int wurfEigenschaft = 0)
        {
            int getroffen = 0;
            int versucht  = 0;

            if (feldMulti == 0)
            {
                versucht = d.GetAnzahlWürfe();
            }
            else
            {
                for (int i = 0; i < d.GetAnzahlWürfe(); i++)
                {
                    switch (feldMulti)
                    {
                    case 1:
                        if (d.GetWürfe()[i].GetMultiZiel() == 1)
                        {
                            versucht++;
                        }
                        break;

                    case 2:
                        if (d.GetWürfe()[i].GetMultiZiel() == 2)
                        {
                            versucht++;
                        }
                        break;

                    case 3:
                        if (d.GetWürfe()[i].GetMultiZiel() == 3)
                        {
                            versucht++;
                        }
                        break;

                    default:
                        throw new Exception();
                    }
                }
            }

            for (int i = 0; i < versucht; i++)
            {
                switch (feldMulti)
                {
                case 0:
                    if (d.GetWürfe()[i].IsGetroffenExakt())
                    {
                        getroffen++;
                    }
                    break;

                case 1:
                    if (d.GetWürfe()[i].GetMultiZiel() == 1 && d.GetWürfe()[i].IsGetroffenExakt())
                    {
                        getroffen++;
                    }
                    break;

                case 2:
                    if (d.GetWürfe()[i].GetMultiZiel() == 2 && d.GetWürfe()[i].IsGetroffenExakt())
                    {
                        getroffen++;
                    }
                    break;

                case 3:
                    if (d.GetWürfe()[i].GetMultiZiel() == 3 && d.GetWürfe()[i].IsGetroffenExakt())
                    {
                        getroffen++;
                    }
                    break;

                default:
                    throw new Exception();
                }
            }
            return(new int[] { getroffen, versucht });
        }