Opzione 1 e 2
This commit is contained in:
parent
b548480f07
commit
389d4771ec
102
Program.cs
102
Program.cs
@ -1,9 +1,101 @@
|
|||||||
namespace ordini_ristorante;
|
namespace ordini_ristorante;
|
||||||
|
|
||||||
class Program
|
class Program {
|
||||||
{
|
static void Main(string[] args) {
|
||||||
static void Main(string[] args)
|
Console.Clear();
|
||||||
{
|
Ristorante ristorante = new();
|
||||||
Console.WriteLine("Hello, World!");
|
int scelta = -1;
|
||||||
|
do {
|
||||||
|
Console.WriteLine("Inserire un'opzione:");
|
||||||
|
Console.WriteLine("1. Crea piatto");
|
||||||
|
Console.WriteLine("2. Visualizza menù");
|
||||||
|
Console.WriteLine("3. Crea ordine");
|
||||||
|
Console.WriteLine("4. Annulla ordine");
|
||||||
|
Console.WriteLine("5. Paga ordine");
|
||||||
|
Console.WriteLine("6. Visualizza ordine");
|
||||||
|
Console.WriteLine("0. Esci");
|
||||||
|
Console.Write("Scelta: ");
|
||||||
|
try {
|
||||||
|
scelta = Convert.ToInt32(Console.ReadLine());
|
||||||
|
switch (scelta) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
AggiungiPiatto(ristorante);
|
||||||
|
Console.WriteLine("Piatto aggiunto con successo");
|
||||||
|
Pausa();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
StampaMenu(ristorante);
|
||||||
|
Pausa();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Pausa();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
Pausa();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
Pausa();
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
Pausa();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Opzione non valida.");
|
||||||
|
Pausa();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (FormatException) {
|
||||||
|
Console.WriteLine("Opzione non valida.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (scelta != 0);
|
||||||
|
}
|
||||||
|
static void Pausa() {
|
||||||
|
Console.WriteLine("Premere un tasto per continuare. . .");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AggiungiPiatto(Ristorante p_ristorante) {
|
||||||
|
string nome;
|
||||||
|
string descrizione;
|
||||||
|
float prezzo = -1;
|
||||||
|
|
||||||
|
Console.Write("Nome del piatto: ");
|
||||||
|
nome = Console.ReadLine();
|
||||||
|
|
||||||
|
Console.Write("Descrizione del piatto: ");
|
||||||
|
descrizione = Console.ReadLine();
|
||||||
|
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
Console.Write("Inserire il prezzo: ");
|
||||||
|
prezzo = (float)Convert.ToDouble(Console.ReadLine());
|
||||||
|
if (prezzo < 0) {
|
||||||
|
Console.WriteLine("Prezzo non valido.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (FormatException) {
|
||||||
|
Console.WriteLine("Prezzo non valido.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (prezzo < 0);
|
||||||
|
|
||||||
|
p_ristorante.AggiungiPiatto(new Piatto(nome, descrizione, prezzo));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StampaMenu(Ristorante p_ristorante) {
|
||||||
|
int i = 0;
|
||||||
|
foreach (Piatto p in p_ristorante.GetMenu()) {
|
||||||
|
Console.WriteLine($"Piatto {i + 1}:");
|
||||||
|
p.StampaPiatto();
|
||||||
|
Console.WriteLine();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +1,35 @@
|
|||||||
namespace ordini_ristorante;
|
namespace ordini_ristorante;
|
||||||
|
|
||||||
class Ristorante {
|
class Ristorante {
|
||||||
Piatto[] menu;
|
Piatto[] menu = [];
|
||||||
Ordine[] ordini;
|
Ordine[] ordini = [];
|
||||||
|
|
||||||
|
public Piatto[] GetMenu() {
|
||||||
|
return this.menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ordine[] GetOrdini() {
|
||||||
|
return this.ordini;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetMenu(Piatto[] p_menu) {
|
||||||
|
this.menu = p_menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetOrdini(Ordine[] p_ordini) {
|
||||||
|
this.ordini = p_ordini;
|
||||||
|
}
|
||||||
public void AggiungiPiatto(Piatto p_nuovoPiatto) {
|
public void AggiungiPiatto(Piatto p_nuovoPiatto) {
|
||||||
Piatto[] menuNuovo = new Piatto[this.menu.Length + 1];
|
Piatto[] menuNuovo = new Piatto[this.menu.Length + 1];
|
||||||
this.menu.CopyTo(menuNuovo, 0);
|
this.menu.CopyTo(menuNuovo, 0);
|
||||||
menuNuovo[this.menu.Length + 1] = p_nuovoPiatto;
|
menuNuovo[menuNuovo.Length - 1] = p_nuovoPiatto;
|
||||||
this.menu = menuNuovo;
|
this.menu = menuNuovo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AggiungiOrdine(Ordine p_nuovoOrdine) {
|
public void AggiungiOrdine(Ordine p_nuovoOrdine) {
|
||||||
Ordine[] ordiniNuovo = new Ordine[this.ordini.Length + 1];
|
Ordine[] ordiniNuovo = new Ordine[this.ordini.Length + 1];
|
||||||
this.ordini.CopyTo(ordiniNuovo, 0);
|
this.ordini.CopyTo(ordiniNuovo, 0);
|
||||||
ordiniNuovo[this.ordini.Length + 1] = p_nuovoOrdine;
|
ordiniNuovo[ordiniNuovo.Length - 1] = p_nuovoOrdine;
|
||||||
this.ordini = ordiniNuovo;
|
this.ordini = ordiniNuovo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
bin/Debug/net9.0/ordini_ristorante
Executable file
BIN
bin/Debug/net9.0/ordini_ristorante
Executable file
Binary file not shown.
23
bin/Debug/net9.0/ordini_ristorante.deps.json
Normal file
23
bin/Debug/net9.0/ordini_ristorante.deps.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"runtimeTarget": {
|
||||||
|
"name": ".NETCoreApp,Version=v9.0",
|
||||||
|
"signature": ""
|
||||||
|
},
|
||||||
|
"compilationOptions": {},
|
||||||
|
"targets": {
|
||||||
|
".NETCoreApp,Version=v9.0": {
|
||||||
|
"ordini_ristorante/1.0.0": {
|
||||||
|
"runtime": {
|
||||||
|
"ordini_ristorante.dll": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"libraries": {
|
||||||
|
"ordini_ristorante/1.0.0": {
|
||||||
|
"type": "project",
|
||||||
|
"serviceable": false,
|
||||||
|
"sha512": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
bin/Debug/net9.0/ordini_ristorante.dll
Normal file
BIN
bin/Debug/net9.0/ordini_ristorante.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/ordini_ristorante.pdb
Normal file
BIN
bin/Debug/net9.0/ordini_ristorante.pdb
Normal file
Binary file not shown.
12
bin/Debug/net9.0/ordini_ristorante.runtimeconfig.json
Normal file
12
bin/Debug/net9.0/ordini_ristorante.runtimeconfig.json
Normal 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
BIN
obj/Debug/net9.0/apphost
Executable file
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("ordini_ristorante")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("ordini_ristorante")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+499cabf977087ed12801624d0d04a68163f62cae")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b548480f07aff0b16f63b907bd44b887976e89eb")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("ordini_ristorante")]
|
[assembly: System.Reflection.AssemblyProductAttribute("ordini_ristorante")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("ordini_ristorante")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("ordini_ristorante")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
||||||
// Generated by the MSBuild WriteCodeFragment class.
|
// Generato dalla classe WriteCodeFragment di MSBuild.
|
||||||
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
d602e9936fa4dbc102619157e087b18e15103db1cf02e8c19baf93d10a6e8ab1
|
d720b1271e49dc7c90fff3358be4316745aa45de2d86000c3c657a67e67a2db7
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
21df64d530c2916de7570939bc7b9df9bcfb0b5d53b3a9decef760ed2cca8b29
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
/home/Verde/git/ordini_ristorante/bin/Debug/net9.0/ordini_ristorante
|
||||||
|
/home/Verde/git/ordini_ristorante/bin/Debug/net9.0/ordini_ristorante.deps.json
|
||||||
|
/home/Verde/git/ordini_ristorante/bin/Debug/net9.0/ordini_ristorante.runtimeconfig.json
|
||||||
|
/home/Verde/git/ordini_ristorante/bin/Debug/net9.0/ordini_ristorante.dll
|
||||||
|
/home/Verde/git/ordini_ristorante/bin/Debug/net9.0/ordini_ristorante.pdb
|
||||||
|
/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.GeneratedMSBuildEditorConfig.editorconfig
|
||||||
|
/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.AssemblyInfoInputs.cache
|
||||||
|
/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.AssemblyInfo.cs
|
||||||
|
/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.csproj.CoreCompileInputs.cache
|
||||||
|
/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.dll
|
||||||
|
/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/refint/ordini_ristorante.dll
|
||||||
|
/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.pdb
|
||||||
|
/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ordini_ristorante.genruntimeconfig.cache
|
||||||
|
/home/Verde/git/ordini_ristorante/obj/Debug/net9.0/ref/ordini_ristorante.dll
|
||||||
BIN
obj/Debug/net9.0/ordini_ristorante.dll
Normal file
BIN
obj/Debug/net9.0/ordini_ristorante.dll
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
f3dc620128d63ccb502ec85787876a8041f1bc1813b22fa68306e53e67b503ab
|
||||||
BIN
obj/Debug/net9.0/ordini_ristorante.pdb
Normal file
BIN
obj/Debug/net9.0/ordini_ristorante.pdb
Normal file
Binary file not shown.
BIN
obj/Debug/net9.0/ref/ordini_ristorante.dll
Normal file
BIN
obj/Debug/net9.0/ref/ordini_ristorante.dll
Normal file
Binary file not shown.
BIN
obj/Debug/net9.0/refint/ordini_ristorante.dll
Normal file
BIN
obj/Debug/net9.0/refint/ordini_ristorante.dll
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user