public void Cadastrar(Bebes instancia) { FileStream dadosBebes = new FileStream("dados.txt", FileMode.Append, FileAccess.Write); StreamWriter escrita = new StreamWriter(dadosBebes, Encoding.UTF8); escrita.WriteLine(instancia.getNome()); escrita.WriteLine(instancia.getDataNasc()); escrita.WriteLine(instancia.getSexo()); escrita.Close(); dadosBebes.Close(); }
public static void Main(string[] args) { string resposta; Bercario berc = new Bercario(); CadastroPesquisa Acesso = new CadastroPesquisa(); bool resposta1 = true; while (resposta1 == true) { Console.WriteLine("Você deseja cadastrar ou pesquisar?"); resposta = Console.ReadLine(); if (resposta == "cadastrar" || resposta == "CADASTRAR" || resposta == "Cadastrar") { string nome; string data; string sexo; Console.WriteLine("Qual o nome do Bebê?"); nome = Console.ReadLine(); Console.WriteLine("Qual a data de nascimento do bebê ?"); data = Console.ReadLine(); Console.WriteLine("Qual o sexo do Bebê?"); sexo = Console.ReadLine(); Bebes baby = new Bebes(nome, data, sexo); //Console.WriteLine(baby.getNome()); berc.ChecarBebes(baby); Acesso.Cadastrar(baby); } else { Acesso.Pesquisar(); } } }
public void ChecarBebes(Bebes instancia) { if (pre == true) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 4; j++) { berc[i, j] = contador.ToString(); Console.Write(" {0} ", contador); contador++; } Console.WriteLine(); } } if (pre == false) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 4; j++) { Console.Write(" {0} ", berc[i, j]); } Console.WriteLine(); } } pre = false; FileStream Bbtxt = new FileStream("banco.txt", FileMode.Open, FileAccess.Read); StreamReader leitura3 = new StreamReader(Bbtxt, Encoding.UTF8); // for(int i=0; i<5; i++) // { // for(int j=0; j<4; j++) // { // } // Console.WriteLine(); // } // for(int i=0; i<5; i++) // { // for(int j=0; j<4; j++) // { string leit; // leit = leitura3.ReadLine(); // Console.Write(" {0} ", leit); // } // Console.WriteLine(); leitura3.Close(); Bbtxt.Close(); Console.WriteLine("Escolha um Número."); escolha = Console.ReadLine(); for (int i = 0; i < 5; i++) { for (int j = 0; j < 4; j++) { if (berc[i, j] == escolha) { berc[i, j] = instancia.getNome(); } } } // for(int i=0; i<5; i++) // { // for(int j=0; j<4; j++) // { // Console.Write(" {0} ", berc[i,j]); // } // Console.WriteLine(); // } contador = 1; Txt(); }