Miglioria VerificaCorrettezza
This commit is contained in:
parent
ba18d30b82
commit
48c2ab537d
38
Program.cs
38
Program.cs
@ -1,4 +1,5 @@
|
|||||||
namespace Rubrica_Miglioria;
|
using System.Text.RegularExpressions;
|
||||||
|
namespace Rubrica_Miglioria;
|
||||||
|
|
||||||
class Program {
|
class Program {
|
||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
@ -38,7 +39,7 @@ class Program {
|
|||||||
nome = Console.ReadLine().ToLower();
|
nome = Console.ReadLine().ToLower();
|
||||||
nomi[contatore] = nome;
|
nomi[contatore] = nome;
|
||||||
tipologia = "nome";
|
tipologia = "nome";
|
||||||
check2 = VerificaCorrettezza(nome, tipologia);
|
check2 = VerificaCorrettezza(nome, true);
|
||||||
check3 = VerificaDoppione(nome, nomi, contatore);
|
check3 = VerificaDoppione(nome, nomi, contatore);
|
||||||
if (nome.Length > 40) {
|
if (nome.Length > 40) {
|
||||||
Console.WriteLine("il nome non può essere lungo più di 40 caratteri");
|
Console.WriteLine("il nome non può essere lungo più di 40 caratteri");
|
||||||
@ -58,7 +59,7 @@ class Program {
|
|||||||
numeroditelefono = numeroditelefono.ToLower();
|
numeroditelefono = numeroditelefono.ToLower();
|
||||||
numeriditelefono[contatore] = numeroditelefono;
|
numeriditelefono[contatore] = numeroditelefono;
|
||||||
tipologia = "numero di telefono";
|
tipologia = "numero di telefono";
|
||||||
check2 = VerificaCorrettezza(numeroditelefono, tipologia);
|
check2 = VerificaCorrettezza(numeroditelefono, false);
|
||||||
check3 = VerificaDoppione(numeroditelefono, numeriditelefono, contatore);
|
check3 = VerificaDoppione(numeroditelefono, numeriditelefono, contatore);
|
||||||
if (numeroditelefono.Length > 20) {
|
if (numeroditelefono.Length > 20) {
|
||||||
Console.WriteLine("il numero di telefono non può essere lungo più di 20 caratteri");
|
Console.WriteLine("il numero di telefono non può essere lungo più di 20 caratteri");
|
||||||
@ -89,7 +90,7 @@ class Program {
|
|||||||
nomeesatto = Console.ReadLine();
|
nomeesatto = Console.ReadLine();
|
||||||
nomeesatto = nomeesatto.ToLower();
|
nomeesatto = nomeesatto.ToLower();
|
||||||
tipologia = "nome";
|
tipologia = "nome";
|
||||||
check2 = VerificaCorrettezza(nome, tipologia);
|
check2 = VerificaCorrettezza(nome, true);
|
||||||
if (nomeesatto.Length > 40) {
|
if (nomeesatto.Length > 40) {
|
||||||
Console.WriteLine("il nome non può essere lungo più di 40 caratteri");
|
Console.WriteLine("il nome non può essere lungo più di 40 caratteri");
|
||||||
}
|
}
|
||||||
@ -113,7 +114,7 @@ class Program {
|
|||||||
nomeapprossimato = Console.ReadLine();
|
nomeapprossimato = Console.ReadLine();
|
||||||
nomeapprossimato = nomeapprossimato.ToLower();
|
nomeapprossimato = nomeapprossimato.ToLower();
|
||||||
tipologia = "nome";
|
tipologia = "nome";
|
||||||
check2 = VerificaCorrettezza(nome, tipologia);
|
check2 = VerificaCorrettezza(nome, true);
|
||||||
if (nomeapprossimato.Length > 40) {
|
if (nomeapprossimato.Length > 40) {
|
||||||
Console.WriteLine("il nome non può essere lungo più di 40 caratteri");
|
Console.WriteLine("il nome non può essere lungo più di 40 caratteri");
|
||||||
}
|
}
|
||||||
@ -155,25 +156,16 @@ class Program {
|
|||||||
}
|
}
|
||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
static bool VerificaCorrettezza(string p_stringa, string p_tipologia) {
|
static bool VerificaCorrettezza(string p_stringa, bool p_tipologia) {
|
||||||
bool check = false;
|
bool check;
|
||||||
string corretezzanome = "1234567890";
|
const string NOME = "[1-9]+";
|
||||||
string corretezzanumeroditelefono = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZàèéìòùÀÈÉÌÒÙáéíóúÁÉÍÓÚâêîôûÂÊÎÔÛäëïöüÄËÏÖÜãõñÃÕÑçÇß¡¿€£¥¢¤!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ \r\n";
|
const string TELEFONO = "^(?:\\(?\\+?\\d{1,3}\\)?|\\(?00\\d{1,3}\\)?)?[\\s-]?\\d{3}[\\s-]\\d{3}[\\s-]\\d{4}$";
|
||||||
if (p_tipologia == "nome") {
|
|
||||||
for (int i = 0; i < p_stringa.Length; i++) {
|
if (p_tipologia) {
|
||||||
if (corretezzanome.Contains(p_stringa[i])) {
|
check = Regex.IsMatch(p_stringa, NOME);
|
||||||
check = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (p_tipologia == "numero di telefono") {
|
else {
|
||||||
for (int i = 0; i < p_stringa.Length; i++) {
|
check = Regex.IsMatch(p_stringa, TELEFONO);
|
||||||
if (corretezzanumeroditelefono.Contains(p_stringa[i])) {
|
|
||||||
check = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Rubrica_Miglioria")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Rubrica_Miglioria")]
|
||||||
[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+7a8c35dc14d3f94742b1739914f0c1734fbd4634")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ba18d30b825f878ff4872e9e8bcafee9285e8619")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("Rubrica_Miglioria")]
|
[assembly: System.Reflection.AssemblyProductAttribute("Rubrica_Miglioria")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Rubrica_Miglioria")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Rubrica_Miglioria")]
|
||||||
[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 @@
|
|||||||
08edd7693ed88a88b67a3d844ce1f743c8ffacd35a9ff767cd5bae496a22411b
|
b72f6dc1501f598d95d1122abf7006264048d3ea8fe9bd9bdb8a9100a2c2bfb0
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user