private void button1_Click_1(object sender, EventArgs e) { var tig = new Panther(100, true, true, "women", Color.Black); int cletka = zoo + tig; Draw(); MessageBox.Show("Кошка в клетке № " + cletka); }
private void button1_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex > -1) { string level = listBox1.Items[listBox1.SelectedIndex].ToString(); Random rnd = new Random(); Animal tig = null; switch (rnd.Next(0, 4)) { case 0: tig = new Panther(100, true, true, "Women", getRandomColor()); break; case 1: tig = new Panther(100, true, true, "Women", getRandomColor()); break; case 2: tig = new ATiger(Color.Black, true, 4, true, true, "men", getRandomColor()); break; case 3: tig = new ATiger(Color.Black, true, 4, true, true, "men", getRandomColor()); break; } if (tig != null) { int zoos = zoo[level] + tig; try { Draw(); MessageBox.Show("Клетка: " + zoos); } catch (Overflow ex) { MessageBox.Show(ex.Message, "Ошибка переполнения", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Общая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void button1_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex > -1) { string level = listBox1.Items[listBox1.SelectedIndex].ToString(); Random rnd = new Random(); Animal tig = null; switch (rnd.Next(0, 4)) { case 0: tig = new Panther(100, true, true, "Women", getRandomColor()); break; case 1: tig = new Panther(100, true, true, "Women", getRandomColor()); break; case 2: tig = new ATiger(Color.Black, true, 4, true, true, "men", getRandomColor()); break; case 3: tig = new ATiger(Color.Black, true, 4, true, true, "men", getRandomColor()); break; } if (tig != null) { int zoos = zoo[level] + tig; if (zoos > -1) { Draw(); MessageBox.Show("Животное в клетке № " + zoos); } else { MessageBox.Show("На этом уровне нет свободных клеток, перейдите на следующий"); } } } }
public bool LoadData(string filename) { if (!File.Exists(filename)) { return(false); } using (FileStream sr = new FileStream(filename, FileMode.Open)) { string s = ""; string[] strs;; List <string> tmp = new List <string>(); using (StreamReader bs = new StreamReader(sr)) { string line; while ((line = bs.ReadLine()) != null) { tmp.Add(line); } } strs = tmp.ToArray(); if (strs[0].Contains("Kolichectvo:")) { int count = Convert.ToInt32(strs[0].Split(':')[1]); if (zooStages != null) { zooStages.Clear(); } zooStages = new Dictionary <string, ZooStage <Animal> >(); } else { return(false); } int counter = -1; for (int i = 1; i < strs.Length; ++i) { if (strs[i] == "Level") { counter++; zooStages.Add("L" + (counter + 1), new ZooStage <Animal>(null, "L" + (counter + 1))); } else if (strs[i] == "End") { return(true); } else if (strs[i].Split(':')[0] == "Panther") { var tig = new Panther(strs[i].Split(':')[1]); int number = zooStages["L" + (counter + 1)] + tig; if (number == -1) { return(false); } } else if (strs[i].Split(':')[0] == "ATiger") { var tig = new ATiger(strs[i].Split(':')[1]); int number = zooStages["L" + (counter + 1)] + tig; if (number == -1) { return(false); } } } } return(true); }