private void button1_Click(object sender, EventArgs e) { int c = Convert.ToInt32(tbCod.Text); string d = tbDenumire.Text; int ct = Convert.ToInt32(tbCantitate.Text); string p = tbProducator.Text; string data = tbExpirare.Text; string[] vector = tbVector.Text.Trim().Split(','); float[] vP = new float[vector.Length]; for (int i = 0; i < vector.Length; i++) { vP[i] = (float)Convert.ToDouble(vector[i]); } ProdusAlimentar pa = new ProdusAlimentar(c, d, ct, p, data, vP); lista.Add(pa); lista.Sort(); tbCantitate.Clear(); tbCod.Clear(); tbDenumire.Clear(); tbExpirare.Clear(); tbProducator.Clear(); tbVector.Clear(); MessageBox.Show(pa.ToString() + Environment.NewLine); }
public int CompareTo(object obj) { ProdusAlimentar pNou = (ProdusAlimentar)obj; if (producator.Equals(pNou.producator)) { return(1); } else { return(0); } }
public Form1() { InitializeComponent(); float[] v = { 15, 20, 17, 16 }; ProdusAlimentar p1 = new ProdusAlimentar(1, "Mozzarela", 20, "Almond", "01/01/2019", v); ProdusAlimentar p2 = new ProdusAlimentar(2, "Banane", 100, "Martinica", "01/06/2018", v); ProdusAlimentar p3 = new ProdusAlimentar(3, "Nelutu", 1, "Andrei", "niciodata", v); lista.Add(p1); lista.Add(p2); lista.Add(p3); }
public static ProdusAlimentar operator-(ProdusAlimentar pa, float m) { ProdusAlimentar copie = (ProdusAlimentar)pa.Clone(); if (copie.vectorPreturiPeLuni != null) { float[] vector = new float[copie.vectorPreturiPeLuni.Length - 1]; copie.vectorPreturiPeLuni.CopyTo(vector, 0); vector[vector.Length - 1] = m; copie.vectorPreturiPeLuni = vector; } else { copie.vectorPreturiPeLuni = new float[1]; copie.vectorPreturiPeLuni[0] = m; } return(copie); }