Beispiel #1
0
        //konstruktor- wczytywanie słów z pliku. trzeba za każdym razem zmieniać ścieżki.
        // da się coś z tym zrobić?
        public BazaSlow()
        {
            //wczytywanie z pliku łatwych słów
            try
            {
                using (StreamReader sr = new StreamReader("latwe.txt"))
                {
                    string   line;
                    string[] split;
                    Slowo    pom;
                    while ((line = sr.ReadLine()) != null)
                    {
                        split = line.Split(' ');
                        pom   = new Slowo(split[0], split[1]);
                        easyWords.Add(pom);
                    }
                }
            }
            catch (IOException e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
                Environment.Exit(1);
            }

            //wczytywanie z pliku trudnych słów
            try
            {
                using (StreamReader sr = new StreamReader("trudne.txt"))
                {
                    string   line;
                    string[] split;
                    Slowo    pom;
                    while ((line = sr.ReadLine()) != null)
                    {
                        split = line.Split(' ');
                        pom   = new Slowo(split[0], split[1]);
                        hardWords.Add(pom);
                    }
                }
            }
            catch (IOException e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }
Beispiel #2
0
 public void NowaGra(int difficultyLevelPar, string playerNamePar)
 {
     this.difficultyLevel  = difficultyLevelPar;
     this.playerName       = playerNamePar;
     this.points           = ranking.GetPoints(playerNamePar);
     this.odgadnieteLitery = 0;
     this.wpisaneLitery    = new List <char>();
     if (difficultyLevel == 1)
     {
         this.lifes = 5;
         slowo      = BazaSlow.GetLatweSlowo();
     }
     else
     {
         this.lifes = 3;
         slowo      = BazaSlow.GetTrudneSlowo();
     }
 }