-
Notifications
You must be signed in to change notification settings - Fork 0
/
Aula30.cs
53 lines (46 loc) · 1.08 KB
/
Aula30.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
//(construtores) e destrutores
public class Jogador {
public int energia;
public bool vivo;
public string nome;
//construtor é o metodo que e executado automaticamente quando instanciar um objeto da classe
//sobrecarga de contrutores
public Jogador() {
energia = 20;
vivo = true;
nome = "Roberto";
}
public Jogador(string n) {
energia = 70;
vivo = true;
nome = n;
}
public Jogador(string n, int energ) {
energia = energ;
vivo = true;
nome = n;
}
public Jogador(string n, int energ, bool viv) {
energia = energ;
vivo = viv;
nome = n;
}
public void info() {
Console.WriteLine("Nome do jogador....{0} ", nome);
Console.WriteLine("Energia do jogador.{0} ", energia);
Console.WriteLine("Estado do jogador..{0} \n\n", vivo);
}
}
class Principal {
static void Main() {
Jogador j1 = new Jogador();
Jogador j2 = new Jogador("Correa");
Jogador j3 = new Jogador("Marcos", 100);
Jogador j4 = new Jogador("Paulo", 80, true);
j1.info();
j2.info();
j3.info();
j4.info();
}
}