Eliminazione metodo VerificaDoppione
This commit is contained in:
parent
149b3fbbcf
commit
03dfc24f00
21
Program.cs
21
Program.cs
@ -142,13 +142,7 @@ class Program {
|
|||||||
while (scelta != 5);
|
while (scelta != 5);
|
||||||
Console.WriteLine("Chiusura effettuta con successo");
|
Console.WriteLine("Chiusura effettuta con successo");
|
||||||
}
|
}
|
||||||
static bool VerificaDoppione(string p_stringa, string[] p_stringhe, int p_contatore) {
|
|
||||||
bool check = false;
|
|
||||||
if (p_contatore != 0) {
|
|
||||||
for (int i = 0; i < p_contatore && !(p_stringhe[i] == p_stringa); i++) ;
|
|
||||||
}
|
|
||||||
return check;
|
|
||||||
}
|
|
||||||
static bool VerificaCorrettezza(string p_stringa, bool p_tipologia) {
|
static bool VerificaCorrettezza(string p_stringa, bool p_tipologia) {
|
||||||
/*
|
/*
|
||||||
tipologia=true -> Controllo validità nome
|
tipologia=true -> Controllo validità nome
|
||||||
@ -169,8 +163,10 @@ class Program {
|
|||||||
|
|
||||||
static bool Controllo(string p_stringa, bool p_tipologia, int p_contatore) {
|
static bool Controllo(string p_stringa, bool p_tipologia, int p_contatore) {
|
||||||
bool ritorno = true;
|
bool ritorno = true;
|
||||||
if (p_stringa.Length > (p_tipologia ? 40 : 20)) {
|
const int LUNGHEZZA_NOME = 40;
|
||||||
Console.WriteLine($"Il {(p_tipologia ? "nome" : "numero di telefono")} non può essere lungo più di {(p_tipologia ? "40" : "20")} caratteri");
|
const int LUNGHEZZA_TELEFONO = 20;
|
||||||
|
if (p_stringa.Length > (p_tipologia ? LUNGHEZZA_NOME : LUNGHEZZA_TELEFONO)) {
|
||||||
|
Console.WriteLine($"Il {(p_tipologia ? "nome" : "numero di telefono")} non può essere lungo più di {(p_tipologia ? LUNGHEZZA_NOME : LUNGHEZZA_TELEFONO)} caratteri");
|
||||||
ritorno = false;
|
ritorno = false;
|
||||||
}
|
}
|
||||||
if (VerificaCorrettezza(p_stringa, p_tipologia)) {
|
if (VerificaCorrettezza(p_stringa, p_tipologia)) {
|
||||||
@ -178,13 +174,10 @@ class Program {
|
|||||||
ritorno = false;
|
ritorno = false;
|
||||||
}
|
}
|
||||||
if (p_contatore != 0) {
|
if (p_contatore != 0) {
|
||||||
if (check3 == true) {
|
if (p_stringhe.Contains(p_stringa)) {
|
||||||
Console.WriteLine("Questo nome esiste già nelle rubrica");
|
Console.WriteLine($"Questo {(p_tipologia ? "nome" : "numero di telefono")} esiste già nelle rubrica.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ritorno;
|
return ritorno;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user