This commit is contained in:
La Programmatrice Verde 2025-04-05 11:54:10 +02:00
parent b295665093
commit d6b251aae7
22 changed files with 423 additions and 6 deletions

View File

@ -1,5 +1,28 @@
namespace oggetti_2;
class Calciatore {
readonly string name;
readonly string surname;
readonly int age;
readonly int weight;
readonly string role;
public readonly int number;
}
public Calciatore(string name, string surname, int age, int weight, string role, int number) {
this.name = name;
this.surname = surname;
this.age = age;
this.weight = weight;
this.role = role;
this.number = number;
}
public void MostraCalciatore() {
Console.WriteLine($"Nome: {this.name}");
Console.WriteLine($"Cognome: {this.surname}");
Console.WriteLine($"Età: {this.age}");
Console.WriteLine($"Peso: {this.weight}");
Console.WriteLine($"Ruolo: {this.role}");
Console.WriteLine($"Numero di maglia: {this.number}");
}
}

View File

@ -1,9 +1,228 @@
namespace oggetti_2;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
class Program {
static void Main(string[] args) {
Console.Clear();
int scelta;
bool isFound;
Squadra squadra = CreaSquadra();
Console.Clear();
do {
Console.WriteLine("Scegliere un'opzione:");
Console.WriteLine("1. Mostra squadra");
Console.WriteLine("2. Mostra giocatore per numero maglia");
Console.WriteLine("0. Esci");
Console.Write("Scelta: ");
scelta = Convert.ToInt32(Console.ReadLine());
switch (scelta) {
case 0:
break;
case 1:
Console.Clear();
squadra.MostraSquadra();
Pausa();
break;
case 2:
Console.Clear();
isFound = false;
Console.Write("Inserire il numero di maglia da mostrare: ");
scelta = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < squadra.giocatori.Length && !isFound; i++) {
if (squadra.giocatori[i].number == scelta) {
squadra.giocatori[i].MostraCalciatore();
isFound = true;
}
}
if (!isFound) {
Console.WriteLine("Numero maglia non trovato.");
}
Pausa();
break;
}
}
while (scelta != 0);
}
static void Pausa() {
Console.WriteLine("Premere un tasto per continuare. . .");
Console.ReadKey();
Console.Clear();
}
static Squadra CreaSquadra() {
string name;
string surname;
int age;
int weight;
string role;
int number;
Calciatore capitano;
Calciatore centrocampista;
Calciatore attaccanteDestro;
Calciatore attaccanteSinistro;
Calciatore esternoDestro;
Calciatore esternoSinistro;
Calciatore terzinoDestro;
Calciatore terzinoSinistro;
Calciatore difensore;
Calciatore portiere;
string teamName;
string location;
double budget;
int matchesWon;
int matchesLost;
Console.Write("Inserire il nome della squadra: ");
teamName = Console.ReadLine();
Console.Write("Inserire il luogo della squadra: ");
location = Console.ReadLine();
Console.Write("Inserire il budget della squadra: ");
budget = Convert.ToDouble(Console.ReadLine());
Console.Write("Inserire le partite vinte dalla squadra: ");
matchesWon = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire le partite perse dalla squadra: ");
matchesLost = Convert.ToInt32(Console.ReadLine());
role = "capitano";
Console.Write("Inserire il nome del capitano: ");
name = Console.ReadLine();
Console.Write("Inserire il cognome del capitano: ");
surname = Console.ReadLine();
Console.Write("Inserire l'età del capitano: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il peso del capitano: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il numero di maglia del capitano: ");
number = Convert.ToInt32(Console.ReadLine());
capitano = new Calciatore(name, surname, age, weight, role, number);
role = "centrocampista";
Console.Write("Inserire il nome del centrocampista: ");
name = Console.ReadLine();
Console.Write("Inserire il cognome del centrocampista: ");
surname = Console.ReadLine();
Console.Write("Inserire l'età del centrocampista: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il peso del centrocampista: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il numero di maglia del centrocampista: ");
number = Convert.ToInt32(Console.ReadLine());
centrocampista = new Calciatore(name, surname, age, weight, role, number);
role = "attaccanteDestro";
Console.Write("Inserire il nome dell'attaccante destro: ");
name = Console.ReadLine();
Console.Write("Inserire il cognome dell'attaccante destro: ");
surname = Console.ReadLine();
Console.Write("Inserire l'età dell'attaccante destro: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il peso dell'attaccante destro: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il numero di maglia dell'attaccante destro: ");
number = Convert.ToInt32(Console.ReadLine());
attaccanteDestro = new Calciatore(name, surname, age, weight, role, number);
role = "attaccanteSinistro";
Console.Write("Inserire il nome dell'attaccante sinistro: ");
name = Console.ReadLine();
Console.Write("Inserire il cognome dell'attaccante sinistro: ");
surname = Console.ReadLine();
Console.Write("Inserire l'età dell'attaccante sinistro: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il peso dell'attaccante sinistro: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il numero di maglia dell'attaccante sinistro: ");
number = Convert.ToInt32(Console.ReadLine());
attaccanteSinistro = new Calciatore(name, surname, age, weight, role, number);
role = "esternoDestro";
Console.Write("Inserire il nome dell'esterno destro: ");
name = Console.ReadLine();
Console.Write("Inserire il cognome dell'esterno destro: ");
surname = Console.ReadLine();
Console.Write("Inserire l'età dell'esterno destro: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il peso dell'esterno destro: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il numero di maglia dell'esterno destro: ");
number = Convert.ToInt32(Console.ReadLine());
esternoDestro = new Calciatore(name, surname, age, weight, role, number);
role = "esternoSinistro";
Console.Write("Inserire il nome dell'esterno sinistro: ");
name = Console.ReadLine();
Console.Write("Inserire il cognome dell'esterno sinistro: ");
surname = Console.ReadLine();
Console.Write("Inserire l'età dell'esterno sinistro: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il peso dell'esterno sinistro: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il numero di maglia dell'esterno sinistro: ");
number = Convert.ToInt32(Console.ReadLine());
esternoSinistro = new Calciatore(name, surname, age, weight, role, number);
role = "terzinoDestro";
Console.Write("Inserire il nome del terzino destro: ");
name = Console.ReadLine();
Console.Write("Inserire il cognome del terzino destro: ");
surname = Console.ReadLine();
Console.Write("Inserire l'età del terzino destro: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il peso del terzino destro: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il numero di maglia del terzino destro: ");
number = Convert.ToInt32(Console.ReadLine());
terzinoDestro = new Calciatore(name, surname, age, weight, role, number);
role = "terzinoSinistro";
Console.Write("Inserire il nome del terzino sinistro: ");
name = Console.ReadLine();
Console.Write("Inserire il cognome del terzino sinistro: ");
surname = Console.ReadLine();
Console.Write("Inserire l'età del terzino sinistro: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il peso del terzino sinistro: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il numero di maglia del terzino sinistro: ");
number = Convert.ToInt32(Console.ReadLine());
terzinoSinistro = new Calciatore(name, surname, age, weight, role, number);
role = "difensore";
Console.Write("Inserire il nome del difensore: ");
name = Console.ReadLine();
Console.Write("Inserire il cognome del difensore: ");
surname = Console.ReadLine();
Console.Write("Inserire l'età del difensore: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il peso del difensore: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il numero di maglia del difensore: ");
number = Convert.ToInt32(Console.ReadLine());
difensore = new Calciatore(name, surname, age, weight, role, number);
role = "portiere";
Console.Write("Inserire il nome del portiere: ");
name = Console.ReadLine();
Console.Write("Inserire il cognome del portiere: ");
surname = Console.ReadLine();
Console.Write("Inserire l'età del portiere: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il peso del portiere: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("Inserire il numero di maglia del portiere: ");
number = Convert.ToInt32(Console.ReadLine());
portiere = new Calciatore(name, surname, age, weight, role, number);
return new Squadra(capitano, centrocampista, attaccanteDestro, attaccanteSinistro, esternoDestro, esternoSinistro, terzinoDestro, terzinoSinistro, difensore, portiere, teamName, location, budget, matchesWon, matchesLost);
}
}

View File

@ -1,5 +1,79 @@
namespace oggetti_2;
class Squadra {
public readonly Calciatore[] giocatori;
readonly Calciatore capitano;
readonly Calciatore centrocampista;
readonly Calciatore attaccanteDestro;
readonly Calciatore attaccanteSinistro;
readonly Calciatore esternoDestro;
readonly Calciatore esternoSinistro;
readonly Calciatore terzinoDestro;
readonly Calciatore terzinoSinistro;
readonly Calciatore difensore;
readonly Calciatore portiere;
readonly string name;
readonly string location;
readonly double budget;
readonly int matchesWon;
readonly int matchesLost;
public Squadra(Calciatore capitano, Calciatore centrocampista, Calciatore attaccanteDestro, Calciatore attaccanteSinistro, Calciatore esternoDestro, Calciatore esternoSinistro, Calciatore terzinoDestro, Calciatore terzinoSinistro, Calciatore difensore, Calciatore portiere, string name, string location, double budget, int matchesWon, int matchesLost) {
this.capitano = capitano;
this.centrocampista = centrocampista;
this.attaccanteDestro = attaccanteDestro;
this.attaccanteSinistro = attaccanteSinistro;
this.esternoDestro = esternoDestro;
this.esternoSinistro = esternoSinistro;
this.terzinoDestro = terzinoDestro;
this.terzinoSinistro = terzinoSinistro;
this.difensore = difensore;
this.portiere = portiere;
this.name = name;
this.location = location;
this.budget = budget;
this.matchesWon = matchesWon;
this.matchesLost = matchesLost;
this.giocatori = new Calciatore[10];
this.giocatori[0] = capitano;
this.giocatori[1] = centrocampista;
this.giocatori[2] = attaccanteDestro;
this.giocatori[3] = attaccanteSinistro;
this.giocatori[4] = esternoDestro;
this.giocatori[5] = esternoSinistro;
this.giocatori[6] = terzinoDestro;
this.giocatori[7] = terzinoSinistro;
this.giocatori[8] = difensore;
this.giocatori[9] = portiere;
}
public void MostraSquadra() {
Console.WriteLine($"Nome: {this.name}");
Console.WriteLine($"Luogo: {this.location}");
Console.WriteLine($"Budget: {this.budget}");
Console.WriteLine($"Partite vinte: {this.matchesWon}");
Console.WriteLine($"Partite perse: {this.matchesLost}");
Console.WriteLine("Giocatori:");
Console.WriteLine();
this.capitano.MostraCalciatore();
Console.WriteLine();
this.centrocampista.MostraCalciatore();
Console.WriteLine();
this.attaccanteDestro.MostraCalciatore();
Console.WriteLine();
this.attaccanteSinistro.MostraCalciatore();
Console.WriteLine();
this.esternoDestro.MostraCalciatore();
Console.WriteLine();
this.esternoSinistro.MostraCalciatore();
Console.WriteLine();
this.terzinoDestro.MostraCalciatore();
Console.WriteLine();
this.terzinoSinistro.MostraCalciatore();
Console.WriteLine();
this.difensore.MostraCalciatore();
Console.WriteLine();
this.portiere.MostraCalciatore();
}
}

BIN
bin/Debug/net9.0/oggetti_2 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": {
"oggetti_2/1.0.0": {
"runtime": {
"oggetti_2.dll": {}
}
}
}
},
"libraries": {
"oggetti_2/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
}
}
}

View File

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

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

Binary file not shown.

View File

@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("oggetti_2")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b2956650939ba52b18b69c61406cc67633199346")]
[assembly: System.Reflection.AssemblyProductAttribute("oggetti_2")]
[assembly: System.Reflection.AssemblyTitleAttribute("oggetti_2")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -0,0 +1 @@
a2dd44f99e09aff72ba800656ba41222cfc89bcedb09722431397f5413d7cdae

View File

@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = oggetti_2
build_property.ProjectDir = /home/Verde/git/oggetti_2/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 9.0
build_property.EnableCodeStyleSeverity =

View File

@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

Binary file not shown.

View File

@ -0,0 +1 @@
f43b104458d3fa2475f19c3992682e7baabcbe56021e8ef03fd194b28cb3bd53

View File

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

Binary file not shown.

View File

@ -0,0 +1 @@
1496373d1878eaa9cd68f837653dfa0d3707828e2d40b2cec630bff5d4f2ada4

Binary file not shown.

Binary file not shown.

Binary file not shown.