26.08.2014 Views

C# e Orientação a Objetos

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

165 RESPOSTAS<br />

TestaAluno.<br />

1 class TestaAluno<br />

2 {<br />

3 static void Main ()<br />

4 {<br />

5<br />

6 Aluno a1 = new Aluno ();<br />

7 a1. nome = " Marcelo Martins ";<br />

8 a1.rg = " 33333333 -3 ";<br />

9 a1. dataNascimento = " 02/04/1985 ";<br />

10<br />

11 Aluno a2 = new Aluno ();<br />

12 a2. nome = " Rafael Cosentino ";<br />

13 a2.rg = " 222222222 -2 ";<br />

14 a2. dataNascimento = " 30/10/1984 ";<br />

15<br />

16 System . Console . WriteLine (a1. nome );<br />

17 System . Console . WriteLine (a1.rg);<br />

18 System . Console . WriteLine (a1. dataNascimento );<br />

19<br />

20 System . Console . WriteLine (a2. nome );<br />

21 System . Console . WriteLine (a2.rg);<br />

22 System . Console . WriteLine (a2. dataNascimento );<br />

23<br />

24 }<br />

25 }<br />

Código <strong>C#</strong> 3.21: TestaAluno.cs<br />

Resposta do Exercise 3.3<br />

Adicione o seguinte arquivo na pasta orientacao-a-objetos.<br />

1 class Funcionario<br />

2 {<br />

3 public string nome ;<br />

4 public string cargo ;<br />

5 public double salario ;<br />

6 }<br />

Código <strong>C#</strong> 3.22: Funcionario.cs<br />

Resposta do Exercise 3.4<br />

Adicione o seguinte arquivo na pasta orientacao-a-objetos. Depois compile e execute a classe TestaFuncionario.<br />

1 class TestaFuncionario<br />

2 {<br />

3 static void Main ()<br />

4 {<br />

5 Funcionario f1 = new Funcionario ();<br />

6 f1. nome = " Marcelo Martins ";<br />

7 f1. cargo = " Diretor ";<br />

8 f1. salario = 1.800;<br />

9<br />

10 Funcionario f2 = new Funcionario ();<br />

11 f2. nome = " Rafael Cosentino ";<br />

12 f2. cargo = " Professor ";<br />

13 f2. salario = 2.000;<br />

www.facebook.com/k19treinamentos 165

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!