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 170<br />
89 }<br />
90 }<br />
Código <strong>C#</strong> 3.79: TestaConta.cs<br />
Resposta do Exercise 3.14<br />
Crie uma classe chamada Funcionario como a do código abaixo.<br />
1 class Funcionario<br />
2 {<br />
3 public string nome ;<br />
4 public double salario ;<br />
5<br />
6 public Funcionario ( double salario )<br />
7 {<br />
8 this . salario = salario ;<br />
9 }<br />
10 }<br />
Código <strong>C#</strong> 3.80: Funcionario.cs<br />
Resposta do Exercise 3.15<br />
1 using System ;<br />
2<br />
3 class TestaFuncionario<br />
4 {<br />
5 static void Main ()<br />
6 {<br />
7 Funcionario f = new Funcionario (200) ;<br />
8<br />
9 System . Console . WriteLine (" Digite o nome do funcionario : ");<br />
10 string nome = System . Console . ReadLine ();<br />
11 f. nome = nome ;<br />
12<br />
13 int opc = 1;<br />
14 while ( opc != 0)<br />
15 {<br />
16 System . Console . WriteLine ("\n\n");<br />
17 System . Console . WriteLine (" Escolha a opcao desejada :");<br />
18 System . Console . WriteLine ("0 - Sair ");<br />
19 System . Console . WriteLine ("1 - Aumentar salário ");<br />
20 System . Console . WriteLine ("2 - Corrigir nome do funcionário ");<br />
21 System . Console . WriteLine ("3 - Imprimir dados ");<br />
22 System . Console . WriteLine ("\n\n");<br />
23<br />
24 string valorTela = System . Console . ReadLine ();<br />
25 opc = Convert . ToInt32 ( valorTela );<br />
26<br />
27 if ( opc == 1)<br />
28 {<br />
29 System . Console . WriteLine (" Digite o quanto você deseja aumentar : ");<br />
30 valorTela = System . Console . ReadLine ();<br />
31 int aumentar = Convert . ToInt32 ( valorTela );<br />
32<br />
33 if ( aumentar < 0)<br />
34 {<br />
35 System . Console . WriteLine (" ERRO ");<br />
36 }<br />
170 www.k19.com.br