Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace RevisãoProva
- {
- class Pessoa
- {
- public Pessoa[] z= new Pessoa[100];
- public int aux;
- private string nome;
- public string Nome
- {
- get{ return nome;}
- set{ nome = value;}
- }
- private string endereço;
- public string Endereço
- {
- get{ return endereço;}
- set{ endereço = value;}
- }
- private string telefone;
- public string Telefone
- {
- get{return telefone;}
- set{ telefone = value;}
- }
- public Pessoa(string nome, string endereço, string telefone)
- {
- this.nome=nome;
- this.endereço=endereço;
- this.telefone = telefone;
- }
- public virtual void mostrar()
- {
- for (int i = 0; i < aux; i++)
- {
- Console.WriteLine (z [aux].nome);
- Console.WriteLine (z [aux].endereço);
- Console.WriteLine (z [aux].telefone);
- }
- }
- }
- class PessoaFisica : Pessoa
- {
- private string cpf;
- public string Cpf
- {
- get{ return cpf;}
- set{ cpf = value;}
- }
- private string rg;
- public string Rg
- {
- get{ return rg;}
- set{rg = value;}
- }
- public PessoaFisica(string nome, string endereço, string telefone, string cpf, string rg) : base(nome, endereço, telefone)
- {
- this.cpf = cpf;
- this.rg = rg;
- }
- public void cadastrar(PessoaFisica pf1)
- {
- z [aux] = pf1;
- aux++;
- }
- public override void mostrar()
- {
- for (int i = 0; i < aux; i++)
- {
- Console.WriteLine (z [aux].Nome);
- Console.WriteLine (z [aux].Endereço);
- Console.WriteLine (z [aux].Telefone);
- Console.WriteLine (z [aux].cpf);
- Console.WriteLine (z [aux].rg);
- }
- }
- }
- class PessoaJuridica : Pessoa
- {
- private string cnpj;
- public string Cnpj
- {
- get{ return cnpj;}
- set{ cnpj = value;}
- }
- public PessoaJuridica(string nome, string endereço, string telefone, string cnpj): base(nome, endereço, telefone)
- {
- this.cnpj = cnpj;
- }
- public void cadastrari(PessoaJuridica pj1)
- {
- z [aux] = pj1;
- aux++;
- }
- public override void mostrar()
- {
- for (int i = 0; i < aux; i++)
- {
- Console.WriteLine (z [aux].Nome);
- Console.WriteLine (z [aux].Endereço);
- Console.WriteLine (z [aux].Telefone);
- Console.WriteLine (z [aux].cnpj);
- }
- }
- }
- class MainClass
- {
- public static void Main (string[] args)
- {
- Pessoa p1 = new Pessoa ("", "", "");
- PessoaFisica pf;
- PessoaJuridica pj;
- int aux;
- string nome; string endereço; string telefone; string cnpj; string cpf, rg;
- int op = 0;
- Console.WriteLine ("1-Pf, 2-PJ, 0-sair");
- op = int.Parse(Console.ReadLine ());
- while (op != 0)
- {
- if (op == 1)
- {
- Console.Write ("Nome:");
- nome = Console.ReadLine ();
- Console.Write ("Endereço:");
- endereço = Console.ReadLine ();
- Console.Write ("Telefone:");
- telefone = Console.ReadLine ();
- Console.Write ("CPF:");
- cpf = Console.ReadLine ();
- Console.Write ("RG:");
- rg = Console.ReadLine ();
- pf = new PessoaFisica (nome, endereço, telefone, cpf, rg);
- pf.cadastrar (pf);
- }
- if (op == 2)
- {
- Console.Write ("Nome:");
- nome = Console.ReadLine ();
- Console.Write ("Endereço:");
- endereço = Console.ReadLine ();
- Console.Write ("Telefone:");
- telefone = Console.ReadLine ();
- Console.Write ("CNPJ:");
- cnpj = Console.ReadLine ();
- pj = new PessoaJuridica (nome, endereço, telefone, cnpj);
- pj.cadastrari (pj);
- }
- if (op == 3)
- {
- p1.mostrar ();
- }
- Console.WriteLine ("1-Pf, 2-PJ, 3-Mostrar 0-sair");
- op = int.Parse(Console.ReadLine ());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement