Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApplication1
- {
- class Pessoa
- {
- public string Nome { get; set; }
- public Double Altura { get; set; }
- internal void Mostrar()
- {
- Console.WriteLine("Nome: " + this.Nome + " ... Altura: " + this.Altura.ToString("N2"));
- }
- }
- class Time
- {
- public Pessoa Pessoa1 { get; set; }
- public Pessoa Pessoa2 { get; set; }
- public Pessoa Pessoa3 { get; set; }
- public void Mostrar()
- {
- Console.WriteLine("..:: Dados dos membros do time ::..");
- if (this.Pessoa1 != null) this.Pessoa1.Mostrar();
- if (this.Pessoa2 != null) this.Pessoa2.Mostrar();
- if (this.Pessoa3 != null) this.Pessoa3.Mostrar();
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Time time = new Time();
- time.Pessoa1 = new Pessoa();
- time.Pessoa1.Nome = "Leandro";
- time.Pessoa1.Altura = 1.74;
- time.Pessoa2 = new Pessoa();
- time.Pessoa2.Nome = "Vinícios";
- time.Pessoa2.Altura = 1.74;
- time.Mostrar();
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment