26.08.2014 Views

C# e Orientação a Objetos

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

167 RESPOSTAS<br />

Resposta do Exercise 3.7<br />

Altere a classe Aluno.<br />

1 class Aluno<br />

2 {<br />

3 public string nome ;<br />

4 public string rg;<br />

5 public string dataNascimento ;<br />

6<br />

7 // Adicione a linha abaixo<br />

8 public Turma turma ;<br />

9 }<br />

Código <strong>C#</strong> 3.33: Aluno.cs<br />

Resposta do Exercise 3.8<br />

1 class TestaAlunoTurma<br />

2 {<br />

3 static void Main ()<br />

4 {<br />

5 Aluno a = new Aluno ();<br />

6 Turma t = new Turma ();<br />

7<br />

8 a. nome = " Rafael Cosentino ";<br />

9 t. periodo = " Tarde ";<br />

10<br />

11 a. turma = t;<br />

12<br />

13 System . Console . WriteLine (a. nome );<br />

14 System . Console . WriteLine (a. turma . periodo );<br />

15 }<br />

16 }<br />

Código <strong>C#</strong> 3.34: TesteAlunoTurma<br />

Resposta do Exercise 3.9<br />

Crie uma classe chamada Funcionario como no código abaixo.<br />

1 class Funcionario<br />

2 {<br />

3 public string nome ;<br />

4 public double salario ;<br />

5<br />

6 public void AumentaSalario ( double valor )<br />

7 {<br />

8 this . salario += valor ;<br />

9 }<br />

10<br />

11 public string ConsultaDados ()<br />

12 {<br />

13 return " Nome : " + this . nome + "\ nSalário : " + this . salario ;<br />

14 }<br />

15 }<br />

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

www.facebook.com/k19treinamentos 167

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

Saved successfully!

Ooh no, something went wrong!