Last active
February 15, 2021 03:32
-
-
Save abimaelmartell/fb94bfc0e143c0a6e918f689ef7e0525 to your computer and use it in GitHub Desktop.
Clase para Tarea de Programación Orientada a Objetos
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
import learning.business.superAnimals.ElasticHuman; | |
import learning.business.superAnimals.HomoSapiens; | |
import learning.business.superAnimals.Superman; | |
import learning.business.superAnimals.Invisible; | |
import learning.basicGUI.BaseAppGUI; | |
import learning.basicGUI.ImagePanel; | |
import learning.basicGUI.InternalButton; | |
import learning.basicGUI.FlowPanel; | |
import learning.basicGUI.GridPanel; | |
import java.awt.TextArea; | |
import java.awt.event.*; | |
public class FantasticFour extends BaseAppGUI { | |
private static String BASE_IMAGE = "../../../../OOPS/resources/images/supers/Fantastic4/"; | |
private class StretchButton extends InternalButton { | |
public void pushAction() { | |
mrFantastic.stretch(space, imageWidth, imageHeight); | |
} | |
} | |
private class VisibleButton extends InternalButton { | |
public void pushAction() { | |
invisibleWoman.changeVisible(space2); | |
} | |
} | |
private class FlyButton extends InternalButton { | |
public void pushAction() { | |
humanTorch.fly(space3, spaceWidth / 2, spaceHeight / 2); | |
} | |
} | |
private class WalkButton extends InternalButton { | |
public void pushAction() { | |
thing.walk(space4, spaceWidth / 2, spaceHeight / 2); | |
} | |
} | |
private class MouseStretch extends MouseAdapter { | |
public void mousePressed(MouseEvent e) { | |
mrFantastic.stretch(space, e.getX(), e.getY() ); | |
} | |
} | |
private ImagePanel space; | |
private ImagePanel space2; | |
private ImagePanel space3; | |
private ImagePanel space4; | |
private ElasticHuman mrFantastic; | |
private Invisible invisibleWoman; | |
private Superman humanTorch; | |
private HomoSapiens thing; | |
private FlowPanel controlPanel; | |
private StretchButton stretchButton; | |
private FlyButton flyButton; | |
private VisibleButton visibleButton; | |
private WalkButton walkButton; | |
private static int spaceWidth = 600; | |
private static int spaceHeight = 600; | |
private GridPanel gridPanel; | |
private static int renglones = 2; | |
private static int columnas = 2; | |
private static int imageWidth = 70 * 2; | |
private static int imageHeight = 95 * 2; | |
public void createComponents(){ | |
super.createComponents(); | |
space = new ImagePanel(); | |
space2 = new ImagePanel(); | |
space3 = new ImagePanel(); | |
space4 = new ImagePanel(); | |
mrFantastic = new ElasticHuman(); | |
invisibleWoman = new Invisible(); | |
humanTorch = new Superman(); | |
thing = new HomoSapiens(); | |
controlPanel = new FlowPanel(); | |
stretchButton = new StretchButton(); | |
visibleButton = new VisibleButton(); | |
flyButton = new FlyButton(); | |
walkButton = new WalkButton(); | |
gridPanel = new GridPanel(renglones, columnas); | |
} | |
public void distributeComponents(){ | |
space.imageX = 0; | |
space.imageY = 0; | |
space.addMouseListener(new MouseStretch()); | |
space.setImage(BASE_IMAGE + "Reed Richards.jpg", imageWidth, imageHeight); | |
space2.imageX = 0; | |
space2.imageY = 0; | |
space2.setImage(BASE_IMAGE + "Sue Storm.jpg", imageWidth, imageHeight); | |
space3.imageX = 0; | |
space3.imageY = 80; | |
space3.setImage(BASE_IMAGE + "Jhonny Storm.jpg", imageWidth, imageHeight); | |
space4.imageX = 0; | |
space4.imageY = 80; | |
space4.setImage(BASE_IMAGE + "Ben Grimm.jpg", imageWidth, imageHeight); | |
stretchButton.setLabel("< Stetch >"); | |
flyButton.setLabel("< Fly >"); | |
visibleButton.setLabel("< Visible >"); | |
walkButton.setLabel("< Walk >"); | |
controlPanel.add(stretchButton); | |
controlPanel.add(visibleButton); | |
controlPanel.add(flyButton); | |
controlPanel.add(walkButton); | |
gridPanel.add(space); | |
gridPanel.add(space2); | |
gridPanel.add(space3); | |
gridPanel.add(space4); | |
frameGUI.setTitle("Fantastic Four"); | |
frameGUI.setSize(spaceWidth, spaceHeight); | |
frameGUI.setResizable(false); | |
frameGUI.addNorth(controlPanel); | |
frameGUI.addCenter(gridPanel); | |
} | |
public void startApplication() { | |
frameGUI.setVisible(true); | |
} | |
public static void main(String [] args) { | |
FantasticFour app = new FantasticFour(); | |
app.startApplication(); | |
} | |
} |
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
package learning.business.superAnimals; | |
import learning.basicGUI.ImagePanel; | |
public class Invisible extends HomoSapiens { | |
private boolean isVisible; | |
public Invisible() { | |
super(); | |
isVisible = true; | |
} | |
public void changeVisible(ImagePanel space){ | |
isVisible = !isVisible; | |
space.setVisible(isVisible); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment