Nuova aggiunta voce
This commit is contained in:
parent
ba3db65a52
commit
7134c6d495
15
Program.cs
15
Program.cs
@ -8,9 +8,8 @@ class Program {
|
||||
int scelta = 0;
|
||||
string nome = "";
|
||||
string numeroditelefono;
|
||||
bool rubricaEsiste = false;
|
||||
bool rubricaNonVuota = false;
|
||||
bool error;
|
||||
bool check3 = false;
|
||||
int contatore = 0;
|
||||
string nomeesatto;
|
||||
string nomeapprossimato;
|
||||
@ -67,15 +66,13 @@ class Program {
|
||||
}
|
||||
while (error);
|
||||
|
||||
singolavoce = new Voce(nome, numeroditelefono);
|
||||
voci[contatore] = singolavoce;
|
||||
rubrica = new Rubrica(voci);
|
||||
rubrica.AddVocidellarubrica(new Voce(nome, numeroditelefono));
|
||||
contatore++;
|
||||
rubricaEsiste = true;
|
||||
rubricaNonVuota = true;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (rubricaEsiste == false) {
|
||||
if (rubricaNonVuota == false) {
|
||||
Console.WriteLine("devi prima aggiungere una voce in rubrica");
|
||||
}
|
||||
else {
|
||||
@ -98,7 +95,7 @@ class Program {
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (rubricaEsiste == false) {
|
||||
if (rubricaNonVuota == false) {
|
||||
Console.WriteLine("devi prima aggiungere una voce in rubrica");
|
||||
}
|
||||
else {
|
||||
@ -120,7 +117,7 @@ class Program {
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (rubricaEsiste == false) {
|
||||
if (rubricaNonVuota == false) {
|
||||
Console.WriteLine("devi prima aggiungere una voce in rubrica");
|
||||
}
|
||||
else {
|
||||
|
||||
@ -14,6 +14,13 @@ class Rubrica {
|
||||
return this.vocidellarubrica;
|
||||
}
|
||||
|
||||
public void AddVocidellarubrica(Voce p_nuovaVoce) {
|
||||
Voce[] oldRubrica = this.vocidellarubrica;
|
||||
Voce[] newRubrica = new Voce[oldRubrica.Length + 1];
|
||||
Array.Copy(oldRubrica, newRubrica, oldRubrica.Length);
|
||||
newRubrica[oldRubrica.Length] = p_nuovaVoce;
|
||||
this.vocidellarubrica = newRubrica;
|
||||
}
|
||||
public string Ricerca(string p_ricerca, bool p_tipologia, int p_contatore) {
|
||||
/*
|
||||
p_tipologia=true -> ricerca esatta
|
||||
@ -26,7 +33,7 @@ class Rubrica {
|
||||
}
|
||||
return !notFound ? $"Voce trovata:\nNome: {this.vocidellarubrica[i].GetNome()}\nNumero di telefono: {this.vocidellarubrica[i].Getnumeroditelefono()}" : $"Il nome {p_ricerca} non è stato trovato nella rubrica.";
|
||||
}
|
||||
|
||||
|
||||
public void StampaRubricaCompleta(int p_contatore) {
|
||||
for (int i = 0; i < p_contatore; i++) {
|
||||
Console.WriteLine($"Nome: {this.vocidellarubrica[i].GetNome()}");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user