diff --git a/Libro.cs b/Libro.cs index 7254def..7b9945e 100644 --- a/Libro.cs +++ b/Libro.cs @@ -1,5 +1,54 @@ namespace biblioteca; class Libro { + string nome; + double prezzo; + string numeroScaffale; + string numeroPagine; + string casaEditrice; + public Libro(string p_nome, double p_prezzo, string p_numeroScaffale, string p_numeroPagine, string p_casaEditrice) { + this.nome = p_nome; + this.prezzo = p_prezzo; + this.numeroScaffale = p_numeroScaffale; + this.numeroPagine = p_numeroPagine; + this.casaEditrice = p_casaEditrice; + } + + public string GetNome() { + return this.nome; + } + + public double GetPrezzo() { + return this.prezzo; + } + + public string GetNumeroScaffale() { + return this.numeroScaffale; + } + + public string GetNumeroPagine() { + return this.numeroPagine; + } + + public string GetCasaEditrice() { + return this.casaEditrice; + } + + public void SetPrezzo(double p_prezzo) { + this.prezzo = p_prezzo; + } + + public void StampaLibro() { + Console.WriteLine($"Nome: {this.GetNome()}"); + Console.WriteLine($"Prezzo: {this.GetPrezzo()}"); + Console.WriteLine($"Numero scaffale: {this.GetNumeroScaffale()}"); + Console.WriteLine($"Numero pagine: {this.GetNumeroPagine()}"); + Console.WriteLine($"Casa editrice: {this.GetCasaEditrice()}"); + } + + public void ApplicaSconto() { + const double SCONTO = 0.1; + this.SetPrezzo(this.GetPrezzo() - this.GetPrezzo() * SCONTO); + } } \ No newline at end of file diff --git a/Program.cs b/Program.cs index dab8625..5bfe321 100644 --- a/Program.cs +++ b/Program.cs @@ -3,9 +3,9 @@ class Program { static void Main(string[] args) { Console.Clear(); - double quantitàErogata, quantitàContenuta, capienza, quantitàRimasta, quantitàRiempimento; + const int MAX_LIBRI = 10; int scelta, input, i = 0; - Dispenser[] dispensers; + Libro[] biblioteca= new Libro[MAX_LIBRI]; bool oggettoEsistente; (double, bool) ritornoRiempimento; Dispenser elementoRiempimento; @@ -29,14 +29,10 @@ class Program { break; case 1: Console.Clear(); - if (i > dispensers.Length - 1) { - Console.WriteLine($"Errore: non si possono creare più di {dispensers.Length} dispensers."); - } - else { - dispensers[i] = new Dispenser(); - i++; - Console.WriteLine("Dispenser standard creato."); - } + dispensers[i] = new Dispenser(); + i++; + Console.WriteLine("Dispenser standard creato."); + Pausa(); break; case 2: