Importato verifica
This commit is contained in:
118
Cliente.cs
118
Cliente.cs
@@ -1,5 +1,123 @@
|
||||
namespace Verifica_incontri;
|
||||
|
||||
class Cliente {
|
||||
string nome;
|
||||
string cognome;
|
||||
string sesso;
|
||||
string eta;
|
||||
string altezza;
|
||||
string professione;
|
||||
string[] interessi;
|
||||
bool isAvailable = true;
|
||||
|
||||
public Cliente(string p_nome, string p_cognome, string p_sesso, string p_eta, string p_altezza, string p_professione, string[] p_interessi)
|
||||
{
|
||||
this.nome = p_nome;
|
||||
this.cognome = p_cognome;
|
||||
this.sesso = p_sesso;
|
||||
this.eta = p_eta;
|
||||
this.altezza = p_altezza;
|
||||
this.professione = p_professione;
|
||||
this.interessi = p_interessi;
|
||||
}
|
||||
|
||||
public string GetNome()
|
||||
{
|
||||
return this.nome;
|
||||
}
|
||||
|
||||
public string GetCognome()
|
||||
{
|
||||
return this.cognome;
|
||||
}
|
||||
public string GetSesso()
|
||||
{
|
||||
return this.sesso;
|
||||
}
|
||||
|
||||
public string GetEta()
|
||||
{
|
||||
return this.eta;
|
||||
}
|
||||
|
||||
public string GetAltezza()
|
||||
{
|
||||
return this.altezza;
|
||||
}
|
||||
|
||||
public string GetProfessione()
|
||||
{
|
||||
return this.professione;
|
||||
}
|
||||
|
||||
|
||||
public string[] GetInteressi()
|
||||
{
|
||||
return this.interessi;
|
||||
}
|
||||
|
||||
public bool GetIsAvailable()
|
||||
{
|
||||
return this.isAvailable;
|
||||
}
|
||||
|
||||
public void SetNome(string p_nome)
|
||||
{
|
||||
this.nome = p_nome;
|
||||
}
|
||||
|
||||
public void SetCognome(string p_cognome)
|
||||
{
|
||||
this.cognome = p_cognome;
|
||||
}
|
||||
public void SetSesso(string p_sesso)
|
||||
{
|
||||
this.sesso = p_sesso;
|
||||
}
|
||||
|
||||
public void SetEta(string p_eta)
|
||||
{
|
||||
this.eta = p_eta;
|
||||
}
|
||||
|
||||
|
||||
public void SetAltezza(string p_altezza)
|
||||
{
|
||||
this.altezza = p_altezza;
|
||||
}
|
||||
|
||||
public void SetProfessione(string p_professione)
|
||||
{
|
||||
this.professione = p_professione;
|
||||
}
|
||||
|
||||
public void SetInteressi(string[] p_interessi)
|
||||
{
|
||||
this.interessi = p_interessi;
|
||||
}
|
||||
|
||||
public void SetIsAvailable(bool p_isAvailable)
|
||||
{
|
||||
this.isAvailable = p_isAvailable;
|
||||
}
|
||||
|
||||
public void StampaCliente()
|
||||
{
|
||||
string output;
|
||||
Console.WriteLine($"Nome: {this.GetNome()}");
|
||||
Console.WriteLine($"Cognome: {this.GetCognome()}");
|
||||
Console.WriteLine($"Sesso: {this.GetSesso()}");
|
||||
Console.WriteLine($"Età: {this.GetEta()}");
|
||||
Console.WriteLine($"Altezza: {this.GetAltezza()}");
|
||||
Console.WriteLine($"Professione: {this.GetProfessione()}");
|
||||
Console.WriteLine("Interessi: ");
|
||||
for (int i = 0; i < this.interessi.Length; i++)
|
||||
{
|
||||
Console.WriteLine(interessi[i]);
|
||||
}
|
||||
|
||||
output = this.isAvailable ? "Sì" : "No";
|
||||
|
||||
Console.WriteLine($"Disponibile: {output}");
|
||||
}
|
||||
}
|
||||
394
Program.cs
394
Program.cs
@@ -1,9 +1,393 @@
|
||||
namespace Verifica_incontri;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
}
|
||||
}
|
||||
static void Main(string[] args)
|
||||
{
|
||||
const int MAX_CLIENTI = 3; //da mettere a 10 prima di consegnare
|
||||
int scelta = -1;
|
||||
bool eccezione;
|
||||
Cliente[] clienti = new Cliente[MAX_CLIENTI];
|
||||
do
|
||||
{
|
||||
Console.WriteLine("Inserire un'opzione:");
|
||||
Console.WriteLine("1. Inserisci dati cliente");
|
||||
Console.WriteLine("2. Visualizza clienti");
|
||||
Console.WriteLine("3. Cerca partner");
|
||||
Console.WriteLine("4. Pulisci schermo");
|
||||
Console.WriteLine("0. Esci");
|
||||
Console.Write("Scelta: ");
|
||||
eccezione = false;
|
||||
try
|
||||
{
|
||||
scelta = Convert.ToInt32(Console.ReadLine());
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
eccezione = true;
|
||||
Console.WriteLine("Opzione non valida.");
|
||||
Pausa();
|
||||
}
|
||||
if (!eccezione)
|
||||
{
|
||||
switch (scelta)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
InserisciClienti(clienti);
|
||||
Pausa();
|
||||
break;
|
||||
case 2:
|
||||
if (!IsClientiPopulated(clienti))
|
||||
{
|
||||
Console.WriteLine("Errore: è necessario inserire i clienti prima di mostrarli.");
|
||||
}
|
||||
else
|
||||
{
|
||||
StampaClienti(clienti);
|
||||
}
|
||||
Pausa();
|
||||
break;
|
||||
case 3:
|
||||
if (!IsClientiPopulated(clienti))
|
||||
{
|
||||
Console.WriteLine("Errore: è necessario inserire i clienti prima di mostrarli.");
|
||||
}
|
||||
else
|
||||
{
|
||||
CercaPartner(clienti);
|
||||
}
|
||||
Pausa();
|
||||
break;
|
||||
case 4:
|
||||
Console.Clear();
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Opzione non valida");
|
||||
Pausa();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
while (scelta != 0);
|
||||
}
|
||||
|
||||
|
||||
static void Pausa()
|
||||
{
|
||||
Console.WriteLine("Premere un tasto per continuare. . .");
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
static void InserisciClienti(Cliente[] p_clienti)
|
||||
{
|
||||
string nome, cognome, sesso, professione;
|
||||
int eta = -1, altezza = -1, numeroInteressi = -1;
|
||||
string[] interessi;
|
||||
bool eccezione;
|
||||
|
||||
for(int i = 0; i < p_clienti.Length; i++) {
|
||||
Console.WriteLine($"Inserimento dati cliente n. {i + 1}:\n");
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Nome: ");
|
||||
nome = Console.ReadLine();
|
||||
if (string.IsNullOrEmpty(nome))
|
||||
{
|
||||
Console.WriteLine("Errore: inserire un nome.");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
while (string.IsNullOrEmpty(nome));
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Cognome: ");
|
||||
cognome = Console.ReadLine();
|
||||
if (string.IsNullOrEmpty(cognome))
|
||||
{
|
||||
Console.WriteLine("Errore: inserire un cognome.");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
while (string.IsNullOrEmpty(cognome));
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Sesso: ");
|
||||
sesso = Console.ReadLine();
|
||||
if (string.IsNullOrEmpty(sesso))
|
||||
{
|
||||
Console.WriteLine("Errore: inserire un sesso.");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
while (string.IsNullOrEmpty(sesso));
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Età: ");
|
||||
eccezione = false;
|
||||
try
|
||||
{
|
||||
eta = Convert.ToInt32(Console.ReadLine());
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
eccezione = true;
|
||||
Console.WriteLine("Errore: età non valida");
|
||||
Pausa();
|
||||
}
|
||||
if (!eccezione)
|
||||
{
|
||||
if(eta <= 0)
|
||||
{
|
||||
Console.WriteLine("Errore: età non valida");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
}
|
||||
while (eccezione || eta <= 0);
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Altezza (cm): ");
|
||||
eccezione = false;
|
||||
try
|
||||
{
|
||||
altezza = Convert.ToInt32(Console.ReadLine());
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
eccezione = true;
|
||||
Console.WriteLine("Errore: altezza non valida");
|
||||
Pausa();
|
||||
}
|
||||
if (!eccezione)
|
||||
{
|
||||
if (altezza <= 0)
|
||||
{
|
||||
Console.WriteLine("Errore: altezza non valida");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
}
|
||||
while (eccezione || altezza <= 0);
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Professione: ");
|
||||
professione = Console.ReadLine();
|
||||
if (string.IsNullOrEmpty(professione))
|
||||
{
|
||||
Console.WriteLine("Errore: inserire una professione.");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
while (string.IsNullOrEmpty(professione));
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Numero di interessi: ");
|
||||
eccezione = false;
|
||||
try
|
||||
{
|
||||
numeroInteressi = Convert.ToInt32(Console.ReadLine());
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
eccezione = true;
|
||||
Console.WriteLine("Errore: numero di interessi non valido");
|
||||
Pausa();
|
||||
}
|
||||
if (!eccezione)
|
||||
{
|
||||
if (numeroInteressi <= 0)
|
||||
{
|
||||
Console.WriteLine("Errore: numero di interessi non valido");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
}
|
||||
while (eccezione || numeroInteressi <= 0);
|
||||
|
||||
interessi = new string[numeroInteressi];
|
||||
|
||||
for (int j = 0; j < numeroInteressi; j++)
|
||||
{
|
||||
do
|
||||
{
|
||||
Console.Write($"Interesse n. {j + 1}: ");
|
||||
interessi[j] = Console.ReadLine();
|
||||
if (string.IsNullOrEmpty(interessi[j]))
|
||||
{
|
||||
Console.WriteLine("Errore: inserire un'interesse.");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
while (string.IsNullOrEmpty(interessi[j]));
|
||||
}
|
||||
|
||||
p_clienti[i] = new Cliente(nome, cognome, sesso, Convert.ToString(eta), Convert.ToString(altezza), professione, interessi);
|
||||
|
||||
Console.WriteLine($"\n\nCliente {i+1} creato con successo.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
static bool IsClientiPopulated(Cliente[] p_clienti)
|
||||
{
|
||||
bool ritorno;
|
||||
if (p_clienti[0] == null)
|
||||
{
|
||||
ritorno = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ritorno = true;
|
||||
}
|
||||
return ritorno;
|
||||
}
|
||||
|
||||
static void StampaClienti(Cliente[] p_clienti)
|
||||
{
|
||||
for (int i = 0; i < p_clienti.Length; i++)
|
||||
{
|
||||
Console.WriteLine($"Cliente n. {i + 1}:");
|
||||
p_clienti[i].StampaCliente();
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
static void CercaPartner(Cliente[] p_clienti)
|
||||
{
|
||||
string sesso;
|
||||
int etaMin = -1, etaMax = -1, j = 0, scelta = 0;
|
||||
bool eccezione;
|
||||
int[] matches = new int[p_clienti.Length];
|
||||
for (int i = 0;i < p_clienti.Length; i++)
|
||||
{
|
||||
matches[i] = -1;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Inserire il sesso da cercare: ");
|
||||
sesso = Console.ReadLine().ToLower().Trim();
|
||||
if (string.IsNullOrEmpty(sesso))
|
||||
{
|
||||
Console.WriteLine("Errore: inserire un sesso.");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
while (string.IsNullOrEmpty(sesso));
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Inserire l'età minima: ");
|
||||
eccezione = false;
|
||||
try
|
||||
{
|
||||
etaMin = Convert.ToInt32(Console.ReadLine());
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
eccezione = true;
|
||||
Console.WriteLine("Errore: età non valida");
|
||||
Pausa();
|
||||
}
|
||||
if (!eccezione)
|
||||
{
|
||||
if (etaMin <= 0)
|
||||
{
|
||||
Console.WriteLine("Errore: età non valida");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
}
|
||||
while (eccezione || etaMin <= 0);
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Inserire l'età massima: ");
|
||||
eccezione = false;
|
||||
try
|
||||
{
|
||||
etaMax = Convert.ToInt32(Console.ReadLine());
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
eccezione = true;
|
||||
Console.WriteLine("Errore: età non valida");
|
||||
Pausa();
|
||||
}
|
||||
if (!eccezione)
|
||||
{
|
||||
if (etaMax <= 0)
|
||||
{
|
||||
Console.WriteLine("Errore: età non valida");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
}
|
||||
while (eccezione || etaMax <= 0);
|
||||
|
||||
for (int i = 0; i < p_clienti.Length; i++) {
|
||||
if(Convert.ToInt32(p_clienti[i].GetEta()) >= etaMin &&
|
||||
Convert.ToInt32(p_clienti[i].GetEta()) <= etaMax &&
|
||||
p_clienti[i].GetSesso().ToLower().Trim() == sesso)
|
||||
{
|
||||
Console.WriteLine("Trovata una corrispondenza:\n");
|
||||
Console.WriteLine($"Nome: {p_clienti[i].GetNome()}");
|
||||
Console.WriteLine($"Cognome: {p_clienti[i].GetCognome()}");
|
||||
Console.WriteLine($"Età: {p_clienti[i].GetEta()}");
|
||||
Console.WriteLine();
|
||||
matches[j] = i;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
do
|
||||
{
|
||||
Console.WriteLine("Selezionare la corrispondenza:");
|
||||
for (int i = 0; i < matches.Length && matches[i] != -1; i++)
|
||||
{
|
||||
Console.WriteLine($"Corrispondenza n. {i + 1}:\n");
|
||||
Console.WriteLine($"Nome: {p_clienti[matches[i]].GetNome()}");
|
||||
Console.WriteLine($"Cognome: {p_clienti[matches[i]].GetCognome()}");
|
||||
Console.WriteLine($"Età: {p_clienti[matches[i]].GetEta()}");
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.Write("Scelta: ");
|
||||
|
||||
eccezione = false;
|
||||
try
|
||||
{
|
||||
scelta = Convert.ToInt32(Console.ReadLine());
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
eccezione = true;
|
||||
Console.WriteLine("Opzione non valida.");
|
||||
Pausa();
|
||||
}
|
||||
if (!eccezione)
|
||||
{
|
||||
if (scelta < 1 || scelta >= p_clienti.Length)
|
||||
{
|
||||
Console.WriteLine("Opzione non valida.");
|
||||
Pausa();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
while (eccezione && !(scelta < 1 || scelta >= p_clienti.Length)); //controllo non funzionante
|
||||
p_clienti[scelta - 1].SetIsAvailable(false);
|
||||
Console.WriteLine("Match eseguito");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
|
||||
22
obj/Debug/net9.0/Verifica_incontri.AssemblyInfo.cs
Normal file
22
obj/Debug/net9.0/Verifica_incontri.AssemblyInfo.cs
Normal 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("Verifica_incontri")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e070f9f32401399e74a2650d310e4165d36a1e33")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Verifica_incontri")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Verifica_incontri")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
8931e29328ad8e2429f21a218cdadca67edbadc83105ceee98dbc5dc8428974a
|
||||
@@ -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 = Verifica_incontri
|
||||
build_property.ProjectDir = /home/Verde/git/Verifica_incontri/
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||
build_property.EnableCodeStyleSeverity =
|
||||
8
obj/Debug/net9.0/Verifica_incontri.GlobalUsings.g.cs
Normal file
8
obj/Debug/net9.0/Verifica_incontri.GlobalUsings.g.cs
Normal 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;
|
||||
BIN
obj/Debug/net9.0/Verifica_incontri.assets.cache
Normal file
BIN
obj/Debug/net9.0/Verifica_incontri.assets.cache
Normal file
Binary file not shown.
Reference in New Issue
Block a user