Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Lampada{
- boolean estadoDaLampada = false;
- void acender(){
- estadoDaLampada = true;
- }
- void apaga(){
- estadoDaLampada = false;
- }
- void mostrarEstado(){
- if(estadoDaLampada) {
- System.out.println("A lampada está ligada!");
- }else{
- System.out.println("A lampada está desligada!");
- }
- }
- }
- //Pode ser usado o boolean para representar o campo de estado
- class TesteLampada{
- public static void main(String[] args) {
- Lampada lampada = new Lampada();
- lampada.mostrarEstado();
- lampada.acender();
- lampada.mostrarEstado();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment