public void Add(string[] data) { var product = new Product(); //switch on the first element of the string array passed in to the method to determine new class switch (data[0]) { case "Book": product = new Book(data[0], data[1], data[2], double.Parse(data[3]), int.Parse(data[4]), data[5], int.Parse(data[6]), data[7], data[8]); break; case "DressShirt": product = new DressShirt(data[0], data[1], data[2], double.Parse(data[3]), int.Parse(data[4]), data[5], data[6], data[7], int.Parse(data[8]), int.Parse(data[9])); break; case "Movie": product = new Movie(data[0], data[1], data[2], double.Parse(data[3]), int.Parse(data[4]), data[5], int.Parse(data[6]), int.Parse(data[7]), data[8], data[9], data[10], data[11]); break; case "Music": product = new Music(data[0], data[1], data[2], double.Parse(data[3]), int.Parse(data[4]), data[5], int.Parse(data[6]), int.Parse(data[7]), data[8], data[9], data[10], data[11], data[12]); break; case "Pants": product = new Pants(data[0], data[1], data[2], double.Parse(data[3]), int.Parse(data[4]), data[5], data[6], data[7], int.Parse(data[8]), int.Parse(data[9])); break; case "Software": product = new Software(data[0], data[1], data[2], double.Parse(data[3]), int.Parse(data[4]), data[5], int.Parse(data[6]), int.Parse(data[7]), data[8], data[9]); break; case "TShirt": product = new TShirt(data[0], data[1], data[2], double.Parse(data[3]), int.Parse(data[4]), data[5], data[6], data[7], data[8]); break; default: product = new Product("Error", "Error", "Error", 0.0, 0); break; } //add new instance of product to base list object Add(product); }
//setup form for tshirt and display information private void drawTShirt() { TShirt tShirt = (TShirt)product; drawSet(true, true, true, true, false, false, false, false); drawApparel(); textBoxVar4.Text = tShirt.Size; labelVar4.Text = "Size"; }