This commit is contained in:
La Programmatrice Verde 2025-04-18 13:53:33 +02:00
parent 1e60a48eea
commit 93e3321eed
16 changed files with 71 additions and 17 deletions

View File

@ -3,8 +3,8 @@
class Program {
static void Main(string[] args) {
Console.Clear();
const int MAX_LIBRI = 10;
int scelta, j;
const int MAX_LIBRI = 2;
int scelta, libroSelezionato = -1;
Libro[] biblioteca = new Libro[MAX_LIBRI];
bool oggettoEsistente, nomeEsistente, casaEditriceEsistente;
string casaEditrice, nome;
@ -15,6 +15,7 @@ class Program {
Console.WriteLine("2. Mostra biblioteca");
Console.WriteLine("3. Mostra libro");
Console.WriteLine("4. Applica sconto");
Console.WriteLine("5. Pulisci schermo");
Console.WriteLine("0. Esci");
Console.Write("Scelta: ");
scelta = Convert.ToInt32(Console.ReadLine());
@ -70,6 +71,7 @@ class Program {
}
while (scelta < 0 || scelta > biblioteca.Length);
biblioteca[scelta].StampaLibro();
scelta = int.MaxValue;
}
Pausa();
break;
@ -86,16 +88,14 @@ class Program {
else {
Console.WriteLine("Scegliere un nome:");
for (int i = 0; i < biblioteca.Length; i++) {
biblioteca[i].GetNome();
Console.WriteLine();
Console.WriteLine($"{biblioteca[i].GetNome()}");
}
Console.Write("Nome: ");
nome = Console.ReadLine();
Console.WriteLine("Scegliere una casa editrice:");
for (int i = 0; i < biblioteca.Length; i++) {
biblioteca[i].GetCasaEditrice();
Console.WriteLine();
Console.WriteLine($"{biblioteca[i].GetCasaEditrice()}");
}
Console.Write("Casa editrice: ");
casaEditrice = Console.ReadLine();
@ -103,21 +103,24 @@ class Program {
nomeEsistente = false;
casaEditriceEsistente = false;
for (j = 0; j < biblioteca.Length && !nomeEsistente && !casaEditriceEsistente; j++) {
nomeEsistente = biblioteca[j].GetNome() == nome;
casaEditriceEsistente = biblioteca[j].GetCasaEditrice() == casaEditrice;
for (int i = 0; i < biblioteca.Length && !nomeEsistente && !casaEditriceEsistente; i++) {
nomeEsistente = biblioteca[i].GetNome() == nome;
casaEditriceEsistente = biblioteca[i].GetCasaEditrice() == casaEditrice;
libroSelezionato = i;
}
if (!nomeEsistente || !casaEditriceEsistente) {
Console.WriteLine($"Nessun libro di nome {nome} di casa editrice {casaEditrice} esistente.");
}
else {
biblioteca[j].ApplicaSconto();
biblioteca[libroSelezionato].ApplicaSconto();
Console.WriteLine("Sconto applicato.");
}
}
Pausa();
break;
case 5:
Console.Clear();
break;
default:
Console.WriteLine("Opzione non valida.");
Pausa();
@ -146,7 +149,7 @@ class Program {
nome = Console.ReadLine();
do {
Console.Write("Inserire il prezzo del libro:");
Console.Write("Inserire il prezzo del libro: ");
prezzo = Convert.ToDouble(Console.ReadLine());
if (prezzo <= 0) {
Console.WriteLine("Errore: il prezzo non può essere minore o uguale a zero.");
@ -156,7 +159,7 @@ class Program {
while (prezzo <= 0);
do {
Console.Write("Inserire il numero di pagine del libro:");
Console.Write("Inserire il numero di pagine del libro: ");
numeroPagine = Convert.ToInt32(Console.ReadLine());
if (numeroPagine <= 0) {
Console.WriteLine("Errore: il numero di pagine non può essere minore o uguale a zero.");

BIN
bin/Debug/net9.0/biblioteca Executable file

Binary file not shown.

View File

@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v9.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v9.0": {
"biblioteca/1.0.0": {
"runtime": {
"biblioteca.dll": {}
}
}
}
},
"libraries": {
"biblioteca/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

BIN
obj/Debug/net9.0/apphost Executable file

Binary file not shown.

View File

@ -13,10 +13,10 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("biblioteca")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3a03e615888527814e42096963631995b875d7f7")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1e60a48eea80d0ccf5e6ca758d90fd2a0af06775")]
[assembly: System.Reflection.AssemblyProductAttribute("biblioteca")]
[assembly: System.Reflection.AssemblyTitleAttribute("biblioteca")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.
// Generato dalla classe WriteCodeFragment di MSBuild.

View File

@ -1 +1 @@
459e7955ba4252a3be22397cd3b5e71c5d58d11d307354d6993334cac373adf2
b5871efc6e390aebc571734a0cd23a8997474bde51295597dd89db59d417a58f

View File

@ -0,0 +1 @@
a9f6fd306d1f84e9f310005b7ff2d4f04a3fd42213cb5e1e9be2cd058ed91c91

View File

@ -0,0 +1,14 @@
/home/Verde/git/biblioteca/bin/Debug/net9.0/biblioteca
/home/Verde/git/biblioteca/bin/Debug/net9.0/biblioteca.deps.json
/home/Verde/git/biblioteca/bin/Debug/net9.0/biblioteca.runtimeconfig.json
/home/Verde/git/biblioteca/bin/Debug/net9.0/biblioteca.dll
/home/Verde/git/biblioteca/bin/Debug/net9.0/biblioteca.pdb
/home/Verde/git/biblioteca/obj/Debug/net9.0/biblioteca.GeneratedMSBuildEditorConfig.editorconfig
/home/Verde/git/biblioteca/obj/Debug/net9.0/biblioteca.AssemblyInfoInputs.cache
/home/Verde/git/biblioteca/obj/Debug/net9.0/biblioteca.AssemblyInfo.cs
/home/Verde/git/biblioteca/obj/Debug/net9.0/biblioteca.csproj.CoreCompileInputs.cache
/home/Verde/git/biblioteca/obj/Debug/net9.0/biblioteca.dll
/home/Verde/git/biblioteca/obj/Debug/net9.0/refint/biblioteca.dll
/home/Verde/git/biblioteca/obj/Debug/net9.0/biblioteca.pdb
/home/Verde/git/biblioteca/obj/Debug/net9.0/biblioteca.genruntimeconfig.cache
/home/Verde/git/biblioteca/obj/Debug/net9.0/ref/biblioteca.dll

Binary file not shown.

View File

@ -0,0 +1 @@
47110de21d993c562ae89b418c918d0fccbe3ce9a0fe954a85bed6ad0add4480

Binary file not shown.

Binary file not shown.

Binary file not shown.