public void AddGuineaPig(GuineaPig guineaPig) { GuineaPigs.AddAnimal(guineaPig); }
private bool ReadAnimalData(string file, Branch[] branches) { string town = null; using (StreamReader reader = new StreamReader(@file)) { string line = null; line = reader.ReadLine(); if (line != null) { town = line; } Branch branch = GetBranchByTown(branches, town); if (branch == null) // neatpažino miesto { return(false); } while (null != (line = reader.ReadLine())) { string[] values = line.Split(','); char type = line[0]; if (type != 'G') { string name = values[1]; int chipId = int.Parse(values[2]); string breed = values[3]; string owner = values[4]; string phone = values[5]; DateTime vd = DateTime.Parse(values[6]); switch (type) { case 'D': //atkreipkite dėmesį - šunys turi papildomą požymį "aggressive" bool aggressive = bool.Parse(values[7]); Dog dog = new Dog(name, chipId, breed, owner, phone, vd, aggressive); if (!branch.Dogs.Contains(dog)) { branch.AddDog(dog); } break; case 'C': Cat cat = new Cat(name, chipId, breed, owner, phone, vd); if (!branch.Cats.Contains(cat)) { branch.AddCat(cat); } break; } } else { string name = values[1]; string breed = values[2]; string owner = values[3]; string phone = values[4]; DateTime vd = DateTime.Parse(values[5]); GuineaPig guineaPig = new GuineaPig(name, breed, owner, phone, vd); if (!branch.GuineaPigs.Contains(guineaPig)) { branch.AddGuineaPig(guineaPig); } } } return(true); } }
public bool Equals(GuineaPig guineaPig) { return(base.Equals(guineaPig)); }