Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Atividade5Ex1
- {
- public class Agenda
- {
- string[] nome = new string[10];
- int[] idade = new int[10];
- float[] altura = new float[10];
- public void armazenarPessoa(string nome, int index, int idade, float altura) // todos os valores
- {
- for (; index < this.nome.Length; index++)
- {
- this.nome[index] = nome;
- this.idade[index] = idade;
- this.altura[index] = altura;
- }
- }
- public void armazenarPessoa(string nome, int index, float altura) // sem idade
- {
- for (; index < this.nome.Length; index++)
- {
- this.nome[index] = nome;
- this.altura[index] = altura;
- }
- }
- public void armazenarPessoa(string nome, int index, int idade) // sem altura
- {
- for (; index < this.nome.Length; index++)
- {
- this.nome[index] = nome;
- this.idade[index] = idade;
- }
- }
- public void armazenarPessoa(string nome, int index) // sem idade e altura
- {
- for (; index < this.nome.Length; index++)
- {
- this.nome[index] = nome;
- }
- }
- public void removerPessoa(string nome)
- {
- Console.Clear();
- bool flag = false;
- for (int index = 0; index < this.nome.Length; index++)
- {
- if (this.nome[index].Contains(nome))
- {
- flag = true;
- this.nome[index] = null;
- this.idade[index] = 0;
- this.altura[index] = 0;
- }
- }
- if (flag == true)
- {
- System.Console.WriteLine("A pessoa {0} foi deletada do sistema com sucesso.", nome);
- }
- else
- {
- System.Console.WriteLine("Não foi possível deletar a pessoa {0}, ela não existe ou seu nome foi digitado incorretamente.", nome);
- }
- }
- public int buscaPessoa(string nome)
- {
- int i = 0;
- for (int index = 0; index < this.nome.Length; index++)
- {
- if (this.nome[index].Contains(nome))
- {
- i = index;
- }
- }
- return i;
- }
- public void imprimeAgenda()
- {
- for (int index = 0; index < nome.Length; index++)
- {
- string resposta = "| Nome: {0} | Idade: {1} anos | Altura: {2} m |";
- System.Console.WriteLine(resposta, this.nome[index], this.idade[index], this.altura[index]);
- }
- }
- public void imprimePessoa(int index)
- {
- bool flag = false;
- for (int i = 0; i < this.nome.Length; i++)
- {
- if (i == index)
- {
- flag = true;
- System.Console.WriteLine("| Nome: {0} | Idade: {1} anos | Altura: {2} m |", this.nome[i], this.idade[i], this.altura[i]);
- break;
- }
- }
- if (flag == false)
- {
- Console.WriteLine("O índice {0} é inválido na instância atual.", index);
- }
- }
- ~Agenda()
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment