Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Ejercicio4B;
- public class Triestable {
- private IEstColor estado;
- public void abrir() {
- estado.abrir();
- }
- public void cerrar() {
- estado.cerrar();
- }
- public IEstColor getEstado() {
- return estado;
- }
- private class Rojo implements IEstColor {
- public void abrir() {
- estado = new Amarillo();
- }
- public void cerrar() {
- }
- }
- private class Amarillo implements IEstColor {
- public void abrir() {
- estado = new Verde();
- }
- public void cerrar() {
- estado = new Rojo();
- }
- }
- private class Verde implements IEstColor {
- public void abrir() {
- }
- public void cerrar() {
- estado = new Amarillo();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement