Exemple #1
0
 public void DodajGreDoListy(Gra gra)
 {
     if (!listaGier.Contains(gra))
     {
         listaGier.Add(gra);
     }
 }
Exemple #2
0
 private void buttonZapisz_Click(object sender, EventArgs e)
 {
     try
     {
         Gra gra = new Gra(textBoxTytul.Text, int.Parse(textBoxMinWiek.Text), decimal.Parse(textBoxCena.Text), textBoxOpis.Text);
         gra.ZapiszDoPliku();
         Close();
     }
     catch
     {
         MessageBox.Show("Wpisałeś błędne wartości", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #3
0
 public void ImportujGryZPliku()
 {
     listaGier.Clear();
     //using (StreamReader wczytaj = new StreamReader(@"D:\informatyka\Programowanie\Dodatkowe\WypozyczlniaGierIKsiazek\gry.txt"))
     using (StreamReader wczytaj = new StreamReader(pathGry))
     {
         string linia;
         while ((linia = wczytaj.ReadLine()) != null)
         {
             string[] parametry = linia.Split('|');
             Gra      gra       = new Gra(parametry[0], int.Parse(parametry[1]), decimal.Parse(parametry[2]), parametry[3]);
             DodajGreDoListy(gra);
         }
     }
 }
Exemple #4
0
 public void UsunGre(Gra gra)
 {
     listaGier.Remove(gra);
     ZapiszGryDoPliku();
 }