/// <summary> /// Creating an object of the required class /// </summary> /// <param name="mas">Array with data about object</param> /// <param name="name">Name object</param> /// <param name="numerous">Numerous object</param> /// <returns>Object type Bakery</returns> public Bakery MakeObject(string[] mas, string name, int numerous) { Bakery bakery = null; double volume, price, calorie; volume = Total(1, mas); price = Total(2, mas); calorie = Total(3, mas); switch (name) { case "Лаваш": bakery = new Lavash(mas, volume, price, calorie, numerous); break; case "Хлеб 'Бородинский'": bakery = new Bread(mas, volume, price, calorie, numerous); break; case "Булка": bakery = new Bun(mas, volume, price, calorie, numerous); break; case "Батон": bakery = new Loaf(mas, volume, price, calorie, numerous); break; case "Багет": bakery = new Baget(mas, volume, price, calorie, numerous); break; case "Бублик": bakery = new Bublic(mas, volume, price, calorie, numerous); break; case "Хлеб ржаной": bakery = new BreadRye(mas, volume, price, calorie, numerous); break; default: break; } return(bakery); }
/// <summary> /// Overriding the Equals method /// </summary> /// <param name="obj">Compared object</param> /// <returns>True - if objects same, false - if objects different</returns> public override bool Equals(object obj) { if (obj == null) { return(false); } Baget B = obj as Baget; if (B as Baget == null) { return(false); } for (int i = 0; data_line.Length == B.data_line.Length && i < data_line.Length; i++) { if (data_line[i] != B.data_line[i]) { return(false); } } return(true); }