private void okCreateButton_Click(object sender, EventArgs e) { String scent = scentBox.Text; //blueberry String size = sizeBox.Text; //large String color = colorBox.Text; int quantity = (int)quantityBox.Value; float price = float.Parse(priceBox.Text); bool exists = false; Candle[] cs = candles.arrayOut(); for (int i = 0; i < cs.Length; i++) { if (cs[i].getScent().Equals(scent)) { if (cs[i].getSize().Equals(size)) { //candle already exists don't add it exists = true; } } } //Candle candle = new Candle(scent, size, color, quantity, price); if (exists == false) { candles.add(new Candle(scent, size, color, quantity, price)); } //candles.outPut(); Close(); }
public HomePage() { InitializeComponent(); candles.add(new Candle("Blueberry", "Small", "Blue", 5, 10.99f)); candles.add(new Candle("Creamsicle", "Large", "Orange", 2, 19.99f)); Candle[] candlesArr = candles.arrayOut(); for (int i = 0; i < candlesArr.Length; i++) { if (candlesArr[i] != null) { candleList.Items.Add(new ListViewItem(new[] { candlesArr[i].getScent(), candlesArr[i].getSize(), candlesArr[i].getColor(), candlesArr[i].getQuantity().ToString(), candlesArr[i].getPrice().ToString() })); } } }