So habe ich diesen Code, mein Problem ist, dass ich mit dem Code des Artikels (codigo) finden, was ist das Produkt und Preis (precio).Ich möchte den Preis mit einem bestimmten Produkt verbunden
Etwas, als ob ich setze '01' es mich auf dem Bildschirm zeigen, welches Produkt es ist und wie viel es kostet, und es dann in die Liste Einkaufen Summe
Das andere Problem ist, dass es eine modulare Programmierung haben kippt (Ja, ich weiß ..) Ursache ist für einen Freund und sein Lehrer ist ein bisschen Esel. Aber wenn es notwendig ist, mach es modular und ich werde versuchen, es später zu ändern.
Ich brauche nur um herauszufinden, wie Produktnamen und Preis mit dem Artikelcode
ich veranlasst, den Code zu entschuldigen erhalten, ist auf spanisch
namespace CodigoSupermercado
{
public struct Lista
{
public double precio;
public string producto;
public int codigo;
}
class Program
{
static void Main(string[] args)
{
Lista[] v;
v = new Lista[10];
v[0].producto = "aceite mezcla"; v[0].precio = 6.00; v[0].codigo = 01;
v[1].producto = "arroz"; v[1].precio = 2.00; v[1].codigo = 02;
v[2].producto = "azucar"; v[2].precio = 3.00; v[2].codigo = 03;
v[3].producto = "caraotas"; v[3].precio = 6.00; v[3].codigo = 04;
v[4].producto = "carne de primera"; v[4].precio = 15.00; v[4].codigo = 05;
v[5].producto = "carne de segunda"; v[5].precio = 10.00; v[5].codigo = 06;
v[6].producto = "harina precocida"; v[6].precio = 2.50; v[6].codigo = 07;
v[7].producto = "leche en polvo"; v[7].precio = 12.00; v[7].codigo = 08;
v[8].producto = "pasta"; v[8].precio = 2.50; v[8].codigo = 09;
v[9].producto = "pollo entero"; v[9].precio = 10.00; v[9].codigo = 10;
Console.WriteLine("Bienvenido al Sistema de Compras");
Console.WriteLine("ELiga los productos a facturar: ");
Console.WriteLine("| Cod | Producto | Precio |");
Console.WriteLine("| 01 |Aceite Mezcla | 6.00 |");
Console.WriteLine("| 02 |Arroz | 2.00 |");
Console.WriteLine("| 03 |Azucar | 3.00 |");
Console.WriteLine("| 04 |Caraotas | 6.00 |");
Console.WriteLine("| 05 |Carne de Primera | 15.00 |");
Console.WriteLine("| 06 |Carne de Segunda | 10.00 |");
Console.WriteLine("| 07 |Harina Precocida | 2.50 |");
Console.WriteLine("| 08 |Leche en Polvo | 12.50 |");
Console.WriteLine("| 09 |Pasta | 2.50 |");
Console.WriteLine("| 10 |Pollo Entero | 10.00 |");
Console.WriteLine("");
Console.WriteLine("");
/*here i was thinkin' making a while loop that ask after the input
if another item is gonna be purchased, till (next != 0)*/
}
}
}
Wenn Sie nur 'codigo' verwenden, um Produkte zu finden, warum benutzen Sie nicht eine' Dictionary '? –
UnholySheep
Sie müssen nur durchlaufen und die 'Lista' zurückgeben, die die' .codigo' hat, die Sie wollen? –