Opzioni 2 e 3
This commit is contained in:
parent
371104953b
commit
997d114446
68
Program.cs
68
Program.cs
@ -28,13 +28,30 @@ class Program {
|
|||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
if (rubrica[0] == null) {
|
||||||
|
Console.WriteLine("Errore: rubrica vuota.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
RicercaEsatta(rubrica);
|
||||||
|
}
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
if (rubrica[0] == null) {
|
||||||
|
Console.WriteLine("Errore: rubrica vuota.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Ricerca(rubrica);
|
||||||
|
}
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
if (rubrica[0] == null) {
|
||||||
|
Console.WriteLine("Errore: rubrica vuota.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
MostraRubrica(rubrica);
|
MostraRubrica(rubrica);
|
||||||
|
}
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -69,8 +86,8 @@ class Program {
|
|||||||
const int LUNGHEZZA_TELEFONO = 20;
|
const int LUNGHEZZA_TELEFONO = 20;
|
||||||
const string TELEFONO = "^(?:\\(?\\+?\\d{1,3}\\)?|\\(?00\\d{1,3}\\)?)?[\\s-]?\\d{3}[\\s-]\\d{3}[\\s-]\\d{4}$";
|
const string TELEFONO = "^(?:\\(?\\+?\\d{1,3}\\)?|\\(?00\\d{1,3}\\)?)?[\\s-]?\\d{3}[\\s-]\\d{3}[\\s-]\\d{4}$";
|
||||||
const string EMAIL = "^[\\w.-]+@([\\w-]+\\.)+[\\w-]{2,4}$";
|
const string EMAIL = "^[\\w.-]+@([\\w-]+\\.)+[\\w-]{2,4}$";
|
||||||
const string CONFERMA = "[SsYy]";
|
const string CONFERMA = "[SsYy]{1}";
|
||||||
const string NEGAZIONE = "[Nn]";
|
const string NEGAZIONE = "[Nn]{1}";
|
||||||
string[] voce;
|
string[] voce;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -226,22 +243,17 @@ class Program {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void MostraRubrica(Voce[] p_rubrica) {
|
static void MostraRubrica(Voce[] p_rubrica) {
|
||||||
if (p_rubrica[0] == null) {
|
|
||||||
Console.WriteLine("Errore: rubrica vuota.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (int i = 0; i < p_rubrica.Length && p_rubrica[i] != null; i++) {
|
for (int i = 0; i < p_rubrica.Length && p_rubrica[i] != null; i++) {
|
||||||
Console.WriteLine($"Voce n. {i + 1}:");
|
Console.WriteLine($"Voce n. {i + 1}:");
|
||||||
p_rubrica[i].MostraVoce();
|
p_rubrica[i].MostraVoce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static bool DoesVoceExist(Voce[] p_rubrica, string[] p_voce) {
|
static bool DoesVoceExist(Voce[] p_rubrica, string[] p_voce) {
|
||||||
bool esiste = false;
|
bool esiste = false;
|
||||||
for (int i = 0; i < p_rubrica.Length && p_rubrica[i] != null && !esiste; i++) {
|
for (int i = 0; i < p_rubrica.Length && p_rubrica[i] != null && !esiste; i++) {
|
||||||
for (int j = 2; j < p_voce.Length && !esiste; j++) {
|
for (int j = 2; j < p_voce.Length && !esiste; j++) {
|
||||||
if (p_voce[j] == p_rubrica[i].GetVoceAsArray()[j]) {
|
if (p_voce[j] == p_rubrica[i].GetVoceAsArray()[j] && p_voce[j] != "") {
|
||||||
esiste = true;
|
esiste = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,4 +261,44 @@ class Program {
|
|||||||
|
|
||||||
return esiste;
|
return esiste;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void RicercaEsatta(Voce[] p_rubrica) {
|
||||||
|
string ricerca;
|
||||||
|
do {
|
||||||
|
Console.Write("Inserire il nome da cercare: ");
|
||||||
|
ricerca = Console.ReadLine();
|
||||||
|
if (string.IsNullOrEmpty(ricerca)) {
|
||||||
|
Console.WriteLine("Errore: nome vuoto.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (string.IsNullOrEmpty(ricerca));
|
||||||
|
|
||||||
|
for (int i = 0; i < p_rubrica.Length && p_rubrica[i] != null; i++) {
|
||||||
|
if (p_rubrica[i].GetNome() == ricerca) {
|
||||||
|
Console.WriteLine("Corrispondenza trovata:");
|
||||||
|
p_rubrica[i].MostraVoce();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Ricerca(Voce[] p_rubrica) {
|
||||||
|
string ricerca;
|
||||||
|
do {
|
||||||
|
Console.Write("Inserire il termine da cercare: ");
|
||||||
|
ricerca = Console.ReadLine();
|
||||||
|
if (string.IsNullOrEmpty(ricerca)) {
|
||||||
|
Console.WriteLine("Errore: nome vuoto.");
|
||||||
|
Pausa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (string.IsNullOrEmpty(ricerca));
|
||||||
|
|
||||||
|
for (int i = 0; i < p_rubrica.Length && p_rubrica[i] != null; i++) {
|
||||||
|
if (p_rubrica[i].GetNome().Contains(ricerca)) {
|
||||||
|
Console.WriteLine("Corrispondenza trovata:");
|
||||||
|
p_rubrica[i].MostraVoce();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
Voce.cs
4
Voce.cs
@ -29,4 +29,8 @@ class Voce {
|
|||||||
public string[] GetVoceAsArray() {
|
public string[] GetVoceAsArray() {
|
||||||
return [this.nome, this.cognome, this.telefono, this.cellulare, this.email, this.indirizzo];
|
return [this.nome, this.cognome, this.telefono, this.cellulare, this.email, this.indirizzo];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetNome() {
|
||||||
|
return this.nome;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("vacanzeEstive_rubricaTelefonica")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("vacanzeEstive_rubricaTelefonica")]
|
||||||
[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+adcd853d065d0f5ee33305ce879ad3ab6c752998")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+371104953b7b7c89cc3ce105bb42a1abd2a722cf")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("vacanzeEstive_rubricaTelefonica")]
|
[assembly: System.Reflection.AssemblyProductAttribute("vacanzeEstive_rubricaTelefonica")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("vacanzeEstive_rubricaTelefonica")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("vacanzeEstive_rubricaTelefonica")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
81cb16105158fc67677a8f34f6d4634cc420d130cc85cba0f787d235cb911b77
|
a78438f378acb1585c80b4cdf5f2a5fa8a6c9e2fb3f6656cf473d5dafa412453
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user