Metodi classe
This commit is contained in:
parent
5b11eed20b
commit
16b04931c6
49
Libro.cs
49
Libro.cs
@ -1,5 +1,54 @@
|
|||||||
namespace biblioteca;
|
namespace biblioteca;
|
||||||
|
|
||||||
class Libro {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
16
Program.cs
16
Program.cs
@ -3,9 +3,9 @@
|
|||||||
class Program {
|
class Program {
|
||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
double quantitàErogata, quantitàContenuta, capienza, quantitàRimasta, quantitàRiempimento;
|
const int MAX_LIBRI = 10;
|
||||||
int scelta, input, i = 0;
|
int scelta, input, i = 0;
|
||||||
Dispenser[] dispensers;
|
Libro[] biblioteca= new Libro[MAX_LIBRI];
|
||||||
bool oggettoEsistente;
|
bool oggettoEsistente;
|
||||||
(double, bool) ritornoRiempimento;
|
(double, bool) ritornoRiempimento;
|
||||||
Dispenser elementoRiempimento;
|
Dispenser elementoRiempimento;
|
||||||
@ -29,14 +29,10 @@ class Program {
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
if (i > dispensers.Length - 1) {
|
dispensers[i] = new Dispenser();
|
||||||
Console.WriteLine($"Errore: non si possono creare più di {dispensers.Length} dispensers.");
|
i++;
|
||||||
}
|
Console.WriteLine("Dispenser standard creato.");
|
||||||
else {
|
|
||||||
dispensers[i] = new Dispenser();
|
|
||||||
i++;
|
|
||||||
Console.WriteLine("Dispenser standard creato.");
|
|
||||||
}
|
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user