public void removeItens(int index) { objParameters = new ObjParameters(); ObjItem objItem = objParameters.GetItens()[index]; this.Peso -= objItem.Peso; this.Valor -= objItem.Valor; this.listItens[index] = 0; }
public void addItens(int index, int value) { objParameters = new ObjParameters(); ObjItem objItem = objParameters.GetItens()[index]; if (value == 1) { this.Peso += objItem.Peso; this.Valor += objItem.Valor; } this.listItens.Add(value); }
private void listBox_Mochilas_SelectedIndexChanged(object sender, EventArgs e) { int indexMochila = listBox_Mochilas.SelectedIndex; ObjParameters parameters = new ObjParameters(); ObjMochila objMochila = parameters.GetMochilas()[indexMochila]; listBox_Itens_Mochila.Items.Clear(); for (int i = 0; i < objMochila.ListItens.Count; i++) { if (objMochila.ListItens[i] == 1) { ObjItem item = parameters.GetItens()[i]; listBox_Itens_Mochila.Items.Add(item.Nome + " = " + item.Peso + "Kg - R$ " + item.Valor); } } }
private void listBox_Mochilas_best_SelectedIndexChanged(object sender, EventArgs e) { ObjParameters parameters = new ObjParameters(); string conteudo = listBox_Mochilas_best.SelectedItem.ToString(); int ini = conteudo.IndexOf(" ="); int fin = conteudo.Length - ini; string aux = conteudo.Substring(ini, fin); conteudo = conteudo.Replace(aux, ""); ObjMochila objMochila = parameters.GetMochilas().Single(s => s.Nome == conteudo); listBox_bestItens.Items.Clear(); for (int i = 0; i < objMochila.ListItens.Count; i++) { if (objMochila.ListItens[i] == 1) { ObjItem item = parameters.GetItens()[i]; listBox_bestItens.Items.Add(item.Nome + " = " + item.Peso + "Kg - R$ " + item.Valor); } } }