Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Supermercato
- {
- static class Dati
- {
- static Random r = new Random();
- static public string GeneraCodice()
- {
- string a = "#" + r.Next(1, 10001);
- return a;
- }
- static public int GeneraNProdotti()
- {
- return r.Next(1, 11);
- }
- static public double Generaprezzo()
- {
- int a = r.Next(1, 101);
- return Convert.ToDouble(a);
- }
- static public string GeneraNome()
- {
- string a = "Prodotto " + r.Next(1, 51);
- return a;
- }
- static public string LeggiNome()
- {
- Console.Write("Inserisci nome cassiera: ");
- return Console.ReadLine();
- }
- static public string LeggiCognome()
- {
- Console.Write("Inserisci cognome cassiera: ");
- return Console.ReadLine();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Supermercato
- {
- class Cassiera
- {
- public string Nome { get; set; }
- public string Cognome { get; set; }
- public Cassiera(string n, string c)
- {
- Nome = n;
- Cognome = c;
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Supermercato
- {
- class Prodotto
- {
- public string codice { get; set; }
- public string nome { get; set; }
- public double prezzo { get; set; }
- public Prodotto(string c, string n, double p)
- {
- codice = c;
- nome = n;
- prezzo = p;
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Supermercato
- {
- class Cliente
- {
- Random r = new Random();
- List<Prodotto> Prodotti = new List<Prodotto>();
- public void AddProdotti(Prodotto p)
- {
- Prodotti.Add(p);
- }
- public void StampaProdotti()
- {
- double tot = 0;
- foreach (Prodotto p in Prodotti)
- {
- tot += p.prezzo;
- Console.WriteLine("Codice: {0}\nNome: {1}\nPrezzo: {2} euro\n", p.codice, p.nome, p.prezzo);
- }
- Console.WriteLine("Totale: {0}", tot);
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Supermercato
- {
- class Supermercato
- {
- Queue<Cliente> Clientela=new Queue<Cliente>();
- Cassiera cas;
- public Supermercato(Cassiera c)
- {
- cas = new Cassiera(c.Nome, c.Cognome);
- }
- public void AggiungiClienti(Cliente c)
- {
- int k = Dati.GeneraNProdotti();
- for (int i = 0; i < k; i++)
- {
- c.AddProdotti(new Prodotto(Dati.GeneraCodice(), Dati.GeneraNome(), Dati.Generaprezzo()));
- }
- Clientela.Enqueue(c);
- Console.WriteLine("Cliente in coda.");
- Console.ReadKey();
- }
- public void Paga()
- {
- Console.Clear();
- if (Clientela.Count == 0)
- {
- Console.WriteLine("Coda vuota.");
- Console.ReadKey();
- }
- else
- {
- Cliente c = Clientela.Dequeue();
- c.StampaProdotti();
- Console.ReadKey();
- }
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Supermercato
- {
- class Program
- {
- static void Main(string[] args)
- {
- int scelta = 0;
- Console.Clear();
- Supermercato S1 = new Supermercato(new Cassiera(Dati.LeggiNome(), Dati.LeggiCognome()));
- do
- {
- Console.Clear();
- Console.WriteLine("1. Nuovo Cliente");
- Console.WriteLine("2. Cassa");
- Console.WriteLine("0. Esci");
- scelta = Convert.ToInt32(Console.ReadLine());
- switch (scelta)
- {
- case 1:
- S1.AggiungiClienti(new Cliente());
- break;
- case 2:
- S1.Paga();
- break;
- case 0:
- break;
- }
- } while (scelta != 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement