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.

RESPOSTAS 178<br />

1 abstract class Funcionario<br />

2 {<br />

3 public double Salario { get ; set ; }<br />

4 }<br />

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

A classe de teste não compila.<br />

Resposta do Exercise 10.5<br />

1 class Gerente : Funcionario<br />

2 {<br />

3 public string Usuario { get ; set ; }<br />

4 public string Senha { get ; set ; }<br />

5 }<br />

Código <strong>C#</strong> 10.21: Gerente.cs<br />

Resposta do Exercise 10.6<br />

1 class TestaFuncionario<br />

2 {<br />

3 static void Main ()<br />

4 {<br />

5 Funcionario f = new Gerente ();<br />

6<br />

7 f. Salario = 3000;<br />

8<br />

9 System . Console . WriteLine (f. Salario );<br />

10 }<br />

11 }<br />

Código <strong>C#</strong> 10.22: TestaFuncionario.cs<br />

Resposta do Exercise 10.7<br />

1 abstract class Funcionario<br />

2 {<br />

3 public double Salario { get ; set ; }<br />

4<br />

5 public abstract double CalculaBonificacao ();<br />

6 }<br />

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

178 www.k19.com.br

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

Saved successfully!

Ooh no, something went wrong!