-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCarro.java
56 lines (42 loc) · 1.11 KB
/
Carro.java
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
54
55
56
package conceitos;
import java.util.Scanner;
public class Carro {
private Boolean chave = true;
public Carro() {
setChave(true);
}
public Carro(Boolean chave) {
setChave(chave);
}
private void setChave(Boolean status) {
this.chave = status;
}
private Boolean getChave() {
return this.chave;
}
public void ligar() {
setChave(true);
System.out.println("###Ligado###");
}
public void desligar() {
setChave(false);
System.out.println("###Desligado###");
}
protected void finalize() {
chave = null;
}
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
Carro novoCarro = new Carro();
System.out.println("Digite 1 para ligar \n 2 para desligar");
int opcao = scn.nextInt();
switch (opcao) {
case 1:
novoCarro.ligar();
break;
case 2:
novoCarro.desligar();
break;
}
}
}