So i´ve got this school task where I schould write a consolecode in which I could create various products, simply by typing them in.
I have managed to use an object array to make it easier to handle the creation, editing and deleting of the products.
I wondered if it is possible to store this object array in any kind. When their is a nice way to do it, could you explain it to me?
So with the some help i figured out how to store it now :D. Big Thank you! But now my problem is: that everything goes fine except that the attribute "private double menge" does not get stores.
My Class:
[Serializable]
class Artikel
{
public string artikelnummer;
public string artikelbezeichnung;
private double Menge;
public string Mengeneinheit;
public double Preis;
public void MengeAktualisieren(double abZuBuchung)
{
if (abZuBuchung < -1000 || abZuBuchung > 1000)
{
Console.WriteLine("Eingabe darf den Wert 1000 nicht ueberschreiten und den Wert -1000 nicht unterschreiten!\n");
}
else
{
Menge += abZuBuchung;
Console.WriteLine("\n\nMenge wurde zu: " + MengeAnzeigen() + " geändert!\n");
}
}
public string MengeAnzeigen()
{
return (Menge.ToString());
}
[JsonConstructor]
public Artikel(string anlegen_artikelnummer, string anlegen_artikelbezeichnung, double anlegen_Menge, string anlegen_Mengeneinheit, double anlegen_Preis)
{
artikelnummer = anlegen_artikelnummer;
artikelbezeichnung = anlegen_artikelbezeichnung;
Menge = anlegen_Menge;
Mengeneinheit = anlegen_Mengeneinheit;
Preis = anlegen_Preis;
}
}