private string calculateVolume(string type) { int amount = 0; if (type == "F") { foreach (var i in SelectedData.getIceCreamList()) { if (i.gettype() == "F") { amount += i.getamount(); } } return((amount * 4).ToString()); } else if (type == "M") { foreach (var i in SelectedData.getIceCreamList()) { if (i.gettype() == "M" || i.gettype() == "I") { amount += i.getamount(); } } return((amount * 4).ToString()); } else if (type == "S") { foreach (var i in SelectedData.getIceCreamList()) { if (i.gettype() == "S") { amount += i.getamount(); } } return((amount * 4).ToString()); } else { Console.WriteLine("Unknown IceCream type. Print.cs, calculateVolume method."); return("-1"); } }
//redraw output textbox with updated list private void reDrawOutput() { List <IceCream> selectedList = selectedData.getIceCreamList(); outputTextBox.Text = string.Empty; for (int i = 0; i < selectedList.Count; i++) { string s = selectedList[i].getamount() + " * " + selectedList[i].getname() + "\n"; outputTextBox.Text = outputTextBox.Text + s; } textBox1.Text = String.Empty; }