This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class App { | |
private Painel painel; | |
private Botao botao; | |
public App(GuiFactory guiFactory) { | |
this.painel = guiFactory.criaPainel(); | |
this.botao = guiFactory.criaBotao(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GuiMain { | |
public static void main(String[] args) { | |
GuiFactory factory = new WindowsGuiFactory(); | |
App windowsApp = new App(factory); | |
windowsApp.configuracaoGuiApplication();; | |
System.out.println( ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WindowsGuiFactory implements GuiFactory { | |
@Override | |
public Painel criaPainel() { | |
return new PainelWindows(true); | |
} | |
@Override | |
public Botao criaBotao() { | |
return new BotaoWindows(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LinuxGuiFactory implements GuiFactory { | |
@Override | |
public Painel criaPainel() { | |
return new LinuxPainel(true); | |
} | |
@Override | |
public Botao criaBotao() { | |
return new BotaoLinux(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface GuiFactory { | |
Painel criaPainel(); | |
Botao criaBotao(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BotaoWindows implements Botao { | |
private final String tipoBotao = "Windows"; | |
@Override | |
public void click() { | |
System.out.println("Click " + tipoBotao); | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BotaoLinux implements Botao { | |
private static final String tipoBotao = "Linux"; | |
@Override | |
public void click() { | |
System.out.println("Click " + tipoBotao); | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Painel { | |
boolean isVisivel(); | |
String tipoPainel(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public class Personagem{ | |
private String nome; | |
private String classe; | |
//atributos fisicos | |
private int constituicao; | |
private int forca; | |
private int destreza; | |
private int agilidade; |