├── README.md ├── doc ├── package-list ├── resources │ └── inherit.gif ├── index.html ├── stylesheet.css ├── allclasses-noframe.html ├── allclasses-frame.html ├── lab1 │ ├── package-frame.html │ └── class-use │ │ ├── Main.html │ │ ├── GUIView.html │ │ ├── GoldModel.html │ │ ├── RoundTile.html │ │ ├── GameFactory.html │ │ ├── RectangularTile.html │ │ ├── GameView.html │ │ ├── GameController.html │ │ ├── Position.html │ │ ├── GameOverException.html │ │ ├── Constants.html │ │ ├── IGameFactory.html │ │ └── GoldModel.Directions.html ├── deprecated-list.html ├── constant-values.html └── index-files │ ├── index-7.html │ ├── index-5.html │ ├── index-6.html │ ├── index-3.html │ ├── index-12.html │ ├── index-8.html │ ├── index-1.html │ ├── index-9.html │ ├── index-2.html │ ├── index-11.html │ └── index-13.html ├── bin └── lab1 │ ├── Main.class │ ├── GUIView.class │ ├── Constants.class │ ├── GameModel.class │ ├── GameTile.class │ ├── GameView.class │ ├── GoldModel.class │ ├── Position.class │ ├── RoundTile.class │ ├── GameFactory.class │ ├── IGameFactory.class │ ├── SnakeModel.class │ ├── GameController.class │ ├── GameController$1.class │ ├── GameOverException.class │ ├── RectangularTile.class │ ├── GoldModel$Directions.class │ ├── SnakeModel$Directions.class │ └── GUIView$StartGameListener.class ├── .classpath ├── src └── lab1 │ ├── Constants.java │ ├── IGameFactory.java │ ├── GameOverException.java │ ├── Main.java │ ├── GameTile.java │ ├── GameFactory.java │ ├── Position.java │ ├── RectangularTile.java │ ├── GameModel.java │ ├── RoundTile.java │ ├── GameView.java │ ├── GUIView.java │ ├── GameController.java │ └── GoldModel.java └── .project /README.md: -------------------------------------------------------------------------------- 1 | # Taller01-Snake -------------------------------------------------------------------------------- /doc/package-list: -------------------------------------------------------------------------------- 1 | lab1 2 | -------------------------------------------------------------------------------- /bin/lab1/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/Main.class -------------------------------------------------------------------------------- /bin/lab1/GUIView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GUIView.class -------------------------------------------------------------------------------- /bin/lab1/Constants.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/Constants.class -------------------------------------------------------------------------------- /bin/lab1/GameModel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GameModel.class -------------------------------------------------------------------------------- /bin/lab1/GameTile.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GameTile.class -------------------------------------------------------------------------------- /bin/lab1/GameView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GameView.class -------------------------------------------------------------------------------- /bin/lab1/GoldModel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GoldModel.class -------------------------------------------------------------------------------- /bin/lab1/Position.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/Position.class -------------------------------------------------------------------------------- /bin/lab1/RoundTile.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/RoundTile.class -------------------------------------------------------------------------------- /bin/lab1/GameFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GameFactory.class -------------------------------------------------------------------------------- /bin/lab1/IGameFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/IGameFactory.class -------------------------------------------------------------------------------- /bin/lab1/SnakeModel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/SnakeModel.class -------------------------------------------------------------------------------- /doc/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/doc/resources/inherit.gif -------------------------------------------------------------------------------- /bin/lab1/GameController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GameController.class -------------------------------------------------------------------------------- /bin/lab1/GameController$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GameController$1.class -------------------------------------------------------------------------------- /bin/lab1/GameOverException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GameOverException.class -------------------------------------------------------------------------------- /bin/lab1/RectangularTile.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/RectangularTile.class -------------------------------------------------------------------------------- /bin/lab1/GoldModel$Directions.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GoldModel$Directions.class -------------------------------------------------------------------------------- /bin/lab1/SnakeModel$Directions.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/SnakeModel$Directions.class -------------------------------------------------------------------------------- /bin/lab1/GUIView$StartGameListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIGAROME/Taller01-Snake/HEAD/bin/lab1/GUIView$StartGameListener.class -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/lab1/Constants.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | import java.awt.Dimension; 4 | 5 | /** Provides a fixed size for various games. */ 6 | public enum Constants { 7 | ; 8 | // Safe Singleton pattern, prevent instantiation. 9 | /** An immutable Dimension object of constant size. */ 10 | public static final Dimension SIZE = new Dimension(10, 10); 11 | 12 | /** @return an copy of the Dimension constant. */ 13 | public static Dimension getGameSize() { 14 | // Dimension is a mutable class, copy to prevent mutation. 15 | return new Dimension(SIZE); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/lab1/IGameFactory.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | /** 4 | * Factory interface for available games. 5 | */ 6 | public interface IGameFactory { 7 | /** 8 | * Returns an array with names of games this factory can create. Used by GUI 9 | * list availible games. 10 | */ 11 | public String[] getGameNames(); 12 | 13 | /** 14 | * Returns a new model object for the game corresponding to its Name. 15 | * 16 | * @param gameName 17 | * The name of the game as given by getGameNames() 18 | * @throws IllegalArgumentException 19 | * if no such game 20 | */ 21 | public GameModel createGame(final String gameName); 22 | } 23 | -------------------------------------------------------------------------------- /src/lab1/GameOverException.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | /** 4 | * Thrown by GameModel.doCommand at game termination. The exception contains 5 | * information about how many points the player got. 6 | */ 7 | public class GameOverException extends Exception { 8 | /** 9 | * 10 | */ 11 | private static final long serialVersionUID = -6586608947928120931L; 12 | private final int score; 13 | 14 | /** Constructs a new exception with the final score. 15 | * 16 | * @param score The final score of the game. 17 | */ 18 | public GameOverException(final int score) { 19 | this.score = score; 20 | } 21 | 22 | /** Get the score of the game */ 23 | public int getScore() { 24 | return this.score; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/lab1/Main.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | import javax.swing.JFrame; 4 | 5 | /** 6 | * This class creates an AWT window which will contain the game. 7 | */ 8 | public class Main { 9 | public static void main(final String[] args) { 10 | // Create a new frame (a window) 11 | JFrame frame = new JFrame(); 12 | 13 | GUIView guiView = new GUIView(new GameFactory()); 14 | 15 | frame.setTitle("Games 2.0"); 16 | 17 | // Add gui to window 18 | frame.add(guiView); 19 | 20 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 21 | 22 | // pack() will do the layout of the window so it gets the correct size 23 | frame.pack(); 24 | 25 | // Open the window 26 | frame.setVisible(true); 27 | frame.requestFocus(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Snake 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | 19 | 1665023977247 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/lab1/GameTile.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | import java.awt.Dimension; 4 | import java.awt.Graphics; 5 | 6 | /** 7 | * A game tile manages painting of a special area of the screen. 8 | * 9 | * Whenever the object should paint itself, it is told what size and position 10 | * that should be used to paint it. 11 | */ 12 | public class GameTile { 13 | 14 | /** 15 | * Draws itself in a given graphics context, position and size. 16 | * 17 | * @param g 18 | * graphics context to draw on. 19 | * @param x 20 | * pixel x coordinate of the tile to be drawn. 21 | * @param y 22 | * pixel y coordinate of the tile to be drawn. 23 | * @param d 24 | * size of this object in pixels. 25 | */ 26 | public void draw(Graphics g, int x, int y, Dimension d) { 27 | // The default GameTile is transparent, 28 | // therefore no drawing is performed. 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/lab1/GameFactory.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | /** 4 | * Factory class for available games. 5 | */ 6 | public class GameFactory implements IGameFactory { 7 | 8 | /** 9 | * Returns an array with names of games this factory can create. Used by GUI 10 | * list availible games. 11 | */ 12 | @Override 13 | public String[] getGameNames() { 14 | return new String[] { "Gold", "Snake" }; 15 | } 16 | 17 | /** 18 | * Returns a new model object for the game corresponding to its Name. 19 | * 20 | * @param gameName 21 | * The name of the game as given by getGameNames() 22 | * @throws IllegalArgumentException 23 | * if no such game 24 | */ 25 | @Override 26 | public GameModel createGame(final String gameName) { 27 | if (gameName.equals("Gold")) { 28 | return new GoldModel(); 29 | } 30 | 31 | else if (gameName.equals("Snake")) { 32 | return new SnakeModel(); 33 | } 34 | 35 | throw new IllegalArgumentException("No such game: " + gameName); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/lab1/Position.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | /** 4 | * Immutable class describing integer 2D-points. 5 | * 6 | * @author evensen 7 | * 8 | */ 9 | public class Position { 10 | private final int x; 11 | private final int y; 12 | 13 | /** 14 | * Creates an immutable instance of a 2D integer coordinate. 15 | */ 16 | public Position(final int x, final int y) { 17 | this.x = x; 18 | this.y = y; 19 | } 20 | 21 | /** 22 | * @return The x value of the coordinate. 23 | */ 24 | public int getX() { 25 | return this.x; 26 | } 27 | 28 | /** 29 | * @return The x value of the coordinate. 30 | */ 31 | public int getY() { 32 | return this.y; 33 | } 34 | 35 | @Override 36 | public int hashCode() { 37 | return 23456789 * this.x + 56789123 * this.y; 38 | } 39 | 40 | @Override 41 | public boolean equals(final Object obj) { 42 | if (this == obj) { 43 | return true; 44 | } 45 | if (obj == null || getClass() != obj.getClass()) { 46 | return false; 47 | } 48 | Position other = (Position) obj; 49 | return this.x == other.x && this.y == other.y; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/lab1/RectangularTile.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | import java.awt.Color; 4 | import java.awt.Dimension; 5 | import java.awt.Graphics; 6 | 7 | 8 | /** 9 | * A rectangular tile manages painting of a 10 | * filled rectangle in a specified area of the screen. 11 | * 12 | * Whenever the object should paint itself, 13 | * it is told what size and position that 14 | * should be used to paint it. 15 | */ 16 | public class RectangularTile extends GameTile { 17 | 18 | /** The color of the rectangle */ 19 | private final Color color; 20 | 21 | /** 22 | * Creates a rectangular game tile. 23 | * 24 | * @param color 25 | * the color of the rectangle. 26 | */ 27 | public RectangularTile(final Color color) { 28 | this.color = color; 29 | } 30 | 31 | /** 32 | * Draws itself in a given graphics context, position and size. 33 | * 34 | * @param g 35 | * graphics context to draw on. 36 | * @param x 37 | * pixel x coordinate of the tile to be drawn. 38 | * @param y 39 | * pixel y coordinate of the tile to be drawn. 40 | * @param d 41 | * size of this object in pixels. 42 | */ 43 | @Override 44 | public void draw(final Graphics g, final int x, final int y, 45 | final Dimension d) { 46 | g.setColor(this.color); 47 | g.fillRect(x, y, d.width, d.height); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Generated Documentation (Untitled) 8 | 9 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | <H2> 28 | Frame Alert</H2> 29 | 30 | <P> 31 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 32 | <BR> 33 | Link to<A HREF="lab1/package-summary.html">Non-frame version.</A> 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /doc/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | 3 | /* Define colors, fonts and other style attributes here to override the defaults */ 4 | 5 | /* Page background color */ 6 | body { background-color: #FFFFFF; color:#000000 } 7 | 8 | /* Headings */ 9 | h1 { font-size: 145% } 10 | 11 | /* Table colors */ 12 | .TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ 13 | .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ 14 | .TableRowColor { background: #FFFFFF; color:#000000 } /* White */ 15 | 16 | /* Font used in left-hand frame lists */ 17 | .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 18 | .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 19 | .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 20 | 21 | /* Navigation bar fonts and colors */ 22 | .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ 23 | .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ 24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} 25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} 26 | 27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 29 | 30 | -------------------------------------------------------------------------------- /doc/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 55 | 56 |
Constants 25 |
26 | GameController 27 |
28 | GameFactory 29 |
30 | GameModel 31 |
32 | GameOverException 33 |
34 | GameTile 35 |
36 | GameView 37 |
38 | GoldModel 39 |
40 | GoldModel.Directions 41 |
42 | GUIView 43 |
44 | IGameFactory 45 |
46 | Main 47 |
48 | Position 49 |
50 | RectangularTile 51 |
52 | RoundTile 53 |
54 |
57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /doc/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 55 | 56 |
Constants 25 |
26 | GameController 27 |
28 | GameFactory 29 |
30 | GameModel 31 |
32 | GameOverException 33 |
34 | GameTile 35 |
36 | GameView 37 |
38 | GoldModel 39 |
40 | GoldModel.Directions 41 |
42 | GUIView 43 |
44 | IGameFactory 45 |
46 | Main 47 |
48 | Position 49 |
50 | RectangularTile 51 |
52 | RoundTile 53 |
54 |
57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/lab1/GameModel.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | import java.awt.Dimension; 4 | 5 | /** 6 | * Common superclass for all game model classes. 7 | * 8 | * Constructors of subclasses should initiate matrix elements and additional, 9 | * game-dependent fields. 10 | */ 11 | public abstract class GameModel { 12 | 13 | /** A Matrix containing the state of the gameboard. */ 14 | private final GameTile[][] gameboardState; 15 | 16 | /** The size of the state matrix. */ 17 | private final Dimension gameboardSize = Constants.getGameSize(); 18 | 19 | /** 20 | * Create a new game model. As GameModel is an abstract class, this is only 21 | * intended for subclasses. 22 | */ 23 | protected GameModel() { 24 | this.gameboardState = 25 | new GameTile[this.gameboardSize.width][this.gameboardSize.height]; 26 | } 27 | 28 | /** 29 | * Set the tile on a specified position in the gameboard. 30 | * 31 | * @param pos 32 | * The position in the gameboard matrix. 33 | * @param tile 34 | * The type of tile to paint in specified position 35 | */ 36 | protected void setGameboardState(final Position pos, final GameTile tile) { 37 | setGameboardState(pos.getX(), pos.getY(), tile); 38 | } 39 | 40 | /** 41 | * Set the tile on a specified position in the gameboard. 42 | * 43 | * @param x 44 | * Coordinate in the gameboard matrix. 45 | * @param y 46 | * Coordinate in the gameboard matrix. 47 | * @param tile 48 | * The type of tile to paint in specified position 49 | */ 50 | protected void setGameboardState(final int x, final int y, 51 | final GameTile tile) { 52 | this.gameboardState[x][y] = tile; 53 | } 54 | 55 | /** 56 | * Returns the GameTile in logical position (x,y) of the gameboard. 57 | * 58 | * @param pos 59 | * The position in the gameboard matrix. 60 | */ 61 | public GameTile getGameboardState(final Position pos) { 62 | return getGameboardState(pos.getX(), pos.getY()); 63 | } 64 | 65 | /** 66 | * Returns the GameTile in logical position (x,y) of the gameboard. 67 | * 68 | * @param x 69 | * Coordinate in the gameboard matrix. 70 | * @param y 71 | * Coordinate in the gameboard matrix. 72 | */ 73 | public GameTile getGameboardState(final int x, final int y) { 74 | return this.gameboardState[x][y]; 75 | } 76 | 77 | /** 78 | * Returns the size of the gameboard. 79 | */ 80 | public Dimension getGameboardSize() { 81 | return this.gameboardSize; 82 | } 83 | 84 | /** 85 | * This method is called repeatedly so that the game can update it's state. 86 | * 87 | * @param lastKey 88 | * The most recent keystroke. 89 | */ 90 | public abstract void gameUpdate(int lastKey) throws GameOverException; 91 | 92 | 93 | /** 94 | * Returns the current score. 95 | */ 96 | public abstract int getScore(); 97 | } 98 | -------------------------------------------------------------------------------- /doc/lab1/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | lab1 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | lab1 20 | 21 | 22 | 27 | 28 |
23 | Interfaces  24 | 25 |
26 | IGameFactory
29 | 30 | 31 | 32 | 33 | 58 | 59 |
34 | Classes  35 | 36 |
37 | GameController 38 |
39 | GameFactory 40 |
41 | GameModel 42 |
43 | GameTile 44 |
45 | GameView 46 |
47 | GoldModel 48 |
49 | GUIView 50 |
51 | Main 52 |
53 | Position 54 |
55 | RectangularTile 56 |
57 | RoundTile
60 | 61 | 62 | 63 | 64 | 71 | 72 |
65 | Enums  66 | 67 |
68 | Constants 69 |
70 | GoldModel.Directions
73 | 74 | 75 | 76 | 77 | 82 | 83 |
78 | Exceptions  79 | 80 |
81 | GameOverException
84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/lab1/RoundTile.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | import java.awt.BasicStroke; 4 | import java.awt.Color; 5 | import java.awt.Dimension; 6 | import java.awt.Graphics; 7 | import java.awt.Graphics2D; 8 | import java.awt.Stroke; 9 | 10 | /** 11 | * A round tile manages painting of a circle 12 | * in a specified area of the screen. 13 | * 14 | * Whenever the object should paint itself, 15 | * it is told what size and position that 16 | * should be used to paint it. 17 | */ 18 | public class RoundTile extends GameTile { 19 | 20 | /** The color of the circle */ 21 | private final Color strokeColor; 22 | private final Color fillColor; 23 | private final Stroke stroke; 24 | private final double scale; 25 | 26 | /** 27 | * Creates a circular game tile. 28 | * 29 | * @param fillColor 30 | * the color of the interior of the circle. 31 | */ 32 | public RoundTile(final Color fillColor) { 33 | this(fillColor, fillColor); 34 | } 35 | 36 | /** 37 | * Creates a circular game tile with a stroke around it. 38 | * 39 | * @param strokeColor 40 | * the color of the stroke around the circle. 41 | * @param fillColor 42 | * the color of the interior of the circle. 43 | */ 44 | public RoundTile(final Color strokeColor, final Color fillColor) { 45 | this(strokeColor, fillColor, 1.0); 46 | } 47 | 48 | /** 49 | * Creates a circular game tile with a stroke around it. 50 | * 51 | * @param strokeColor 52 | * the color of the stroke around the circle. 53 | * @param fillColor 54 | * the color of the interior of the circle. 55 | * @param thickness 56 | * the thickness of the stroke. 57 | */ 58 | public RoundTile(final Color strokeColor, final Color fillColor, 59 | final double thickness) { 60 | this(strokeColor, fillColor, thickness, 1.0); 61 | } 62 | 63 | /** 64 | * Creates a circular game tile with a stroke around it. 65 | * 66 | * @param strokeColor 67 | * the color of the stroke around the circle. 68 | * @param fillColor 69 | * the color of the interior of the circle. 70 | * @param thickness 71 | * the thickness of the stroke. 72 | * @param scale 73 | * size of the circle relative to the tile size. 74 | */ 75 | public RoundTile(final Color strokeColor, final Color fillColor, 76 | final double thickness, final double scale) { 77 | this.strokeColor = strokeColor; 78 | this.fillColor = fillColor; 79 | this.stroke = new BasicStroke((float) thickness); 80 | this.scale = scale; 81 | } 82 | 83 | /** 84 | * Draws itself in a given graphics context, position and size. 85 | * 86 | * @param g 87 | * graphics context to draw on. 88 | * @param x 89 | * pixel x coordinate of the tile to be drawn. 90 | * @param y 91 | * pixel y coordinate of the tile to be drawn. 92 | * @param d 93 | * size of this object in pixels. 94 | */ 95 | @Override 96 | public void draw(final Graphics g, final int x, final int y, 97 | final Dimension d) { 98 | Graphics2D g2 = (Graphics2D) g; 99 | g2.setColor(this.fillColor); 100 | double xOffset = (d.width * (1.0 - this.scale)) / 2.0; 101 | double yOffset = (d.height * (1.0 - this.scale)) / 2.0; 102 | g2.fillOval((int) (x + xOffset), (int) (y + yOffset), 103 | (int) (d.width - xOffset * 2), 104 | (int) (d.height - yOffset * 2)); 105 | g2.setStroke(this.stroke); 106 | g2.setColor(this.strokeColor); 107 | g2.drawOval((int) (x + xOffset), (int) (y + yOffset), 108 | (int) (d.width - xOffset * 2), 109 | (int) (d.height - yOffset * 2)); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/lab1/GameView.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | import java.awt.Color; 4 | import java.awt.Dimension; 5 | import java.awt.Font; 6 | import java.awt.Graphics; 7 | import java.awt.Image; 8 | 9 | import javax.swing.JComponent; 10 | 11 | /** 12 | * A view Component suitable for inclusion in an AWT Frame. Paints itself by 13 | * consulting its model. 14 | */ 15 | public class GameView extends JComponent { 16 | 17 | /** 18 | * 19 | */ 20 | private static final long serialVersionUID = 1534474796794225462L; 21 | 22 | /** Size of game model */ 23 | private final Dimension modelSize; 24 | 25 | /** Size of every tile in the model */ 26 | private final Dimension tileSize; 27 | 28 | /** The game model which is drawn */ 29 | private GameModel model; 30 | 31 | /** The offscreen buffer */ 32 | private Graphics offscreenGraphics; 33 | 34 | /** Image representing the offscreen graphics */ 35 | private Image offscreenImage; 36 | 37 | /** 38 | * Creates a view where each GameObject has side length 40 pixels.. 39 | */ 40 | public GameView() { 41 | this(40); 42 | } 43 | 44 | /** 45 | * Creates a view where each GameObject has a given size. 46 | * 47 | * @param tileSide 48 | * side length in pixels of each GameObject. 49 | */ 50 | public GameView(final int tileSide) { 51 | this.tileSize = new Dimension(tileSide, tileSide); 52 | this.modelSize = Constants.getGameSize(); 53 | Dimension preferredSize = 54 | new Dimension(this.modelSize.width * tileSide, 55 | this.modelSize.height * tileSide); 56 | setPreferredSize(preferredSize); 57 | } 58 | 59 | /** 60 | * Updates the view with a new model. 61 | */ 62 | public void setModel(final GameModel model) { 63 | this.model = model; 64 | repaint(); 65 | } 66 | 67 | /** 68 | * This method ensures that the painting is performed double-buffered. This 69 | * means there won't be any flicker when repainting all the time. 70 | */ 71 | @Override 72 | public void update(final Graphics g) { 73 | // Create an offscreen buffer (if we don't have one) 74 | if (this.offscreenImage == null) { 75 | Dimension size = getSize(); 76 | 77 | this.offscreenImage = createImage(size.width, size.height); 78 | this.offscreenGraphics = this.offscreenImage.getGraphics(); 79 | } 80 | 81 | // This will invoke painting correctly on the offscreen buffer 82 | super.update(this.offscreenGraphics); 83 | 84 | // Draw the contents of the offscreen buffer to screen. 85 | g.drawImage(this.offscreenImage, 0, 0, this); 86 | } 87 | 88 | /** 89 | * Consults the model to paint the game matrix. If model is null, draws a 90 | * default text. 91 | */ 92 | @Override 93 | public void paintComponent(final Graphics g) { 94 | // Check if we have a running game 95 | super.paintComponent(g); 96 | g.setColor(this.getBackground()); 97 | g.fillRect(0, 0, getWidth(), getHeight()); 98 | 99 | if (this.model != null) { 100 | 101 | /* 102 | * Show the current score in the graphics context. Requires a 103 | * getter method in the model (forced by having an abstract 104 | * 'getScore' method in GameModel). 105 | */ 106 | g.setColor(Color.BLACK); 107 | g.setFont(new Font("Sans", Font.BOLD, 14)); 108 | 109 | String scoreString = (this.model.getScore() == 1) ? "point" : "points"; 110 | g.drawString(this.model.getScore() + " " + scoreString, 10, 20); 111 | 112 | // Draw all tiles by going over them x-wise and y-wise. 113 | for (int i = 0; i < this.modelSize.width; i++) { 114 | for (int j = 0; j < this.modelSize.height; j++) { 115 | GameTile tile = this.model.getGameboardState(i, j); 116 | tile.draw(g, i * this.tileSize.width, j 117 | * this.tileSize.height, 118 | this.tileSize); 119 | } 120 | } 121 | } else { 122 | g.setFont(new Font("Sans", Font.BOLD, 24)); 123 | g.setColor(Color.BLACK); 124 | final char[] message = "No model chosen.".toCharArray(); 125 | g.drawChars(message, 0, message.length, 50, 50); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/lab1/GUIView.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Color; 5 | import java.awt.event.ActionEvent; 6 | import java.awt.event.ActionListener; 7 | 8 | import javax.swing.JButton; 9 | import javax.swing.JComboBox; 10 | import javax.swing.JPanel; 11 | 12 | /** 13 | * This panel is meant to be the base of a window or applet. It will add a new 14 | * GameView with a corresponding GameController to itself. It will also provide 15 | * a gui for choosing a new game. The list of games will be aquired from 16 | * a GameFactory. 17 | */ 18 | public class GUIView extends JPanel { 19 | /** 20 | * 21 | */ 22 | private static final long serialVersionUID = -3394100357075618465L; 23 | 24 | /** The "Start Game" button */ 25 | private final JButton startGameButton; 26 | 27 | /** The chooser (also called drop-down menu) with names of different games */ 28 | private final JComboBox gameChooser; 29 | 30 | /** The game controller associated with the GameView */ 31 | private final GameController gameController; 32 | 33 | /** The game view on this panel */ 34 | private final GameView gameView; 35 | 36 | /** The panel with the gui-gadgets on this panel */ 37 | private final JPanel guiPanel; 38 | 39 | /** This is the factory which creates GameModels for us */ 40 | private final IGameFactory gameFactory; 41 | 42 | /** 43 | * Create a new GUIView. This will create a GameView and a GameController. 44 | * @param factory The factory to use for creating games. 45 | */ 46 | 47 | public GUIView(IGameFactory factory) { 48 | // Create a new GameView 49 | this.gameView = new GameView(); 50 | 51 | // Create a new GameController connected to the GameView 52 | this.gameController = new GameController(this.gameView); 53 | 54 | // Create a new GameFactory 55 | this.gameFactory = factory; 56 | 57 | // Set the background on the GameView 58 | this.gameView.setBackground(Color.white); 59 | 60 | // Set the layout on myself 61 | setLayout(new BorderLayout()); 62 | 63 | // Make a new panel containing the GUI 64 | this.guiPanel = new JPanel(); 65 | 66 | // Set the background on that panel 67 | this.guiPanel.setBackground(Color.lightGray); 68 | 69 | // Create a new button on that panel and add a StartGameListener as 70 | // listener on that button 71 | this.startGameButton = new JButton("Jugar1S"); 72 | this.startGameButton.addActionListener(new StartGameListener()); 73 | this.guiPanel.add(this.startGameButton); 74 | 75 | // Create a new choice on the panel, and add all available games 76 | this.gameChooser = new JComboBox(this.gameFactory.getGameNames()); 77 | this.guiPanel.add(this.gameChooser); 78 | 79 | // Add both the new panel and the GameView to myself 80 | add(this.gameView, BorderLayout.CENTER); 81 | add(this.guiPanel, BorderLayout.SOUTH); 82 | } 83 | 84 | /** 85 | * Get a reference to the game controller. Useful if game needs to be 86 | * stopped by some other means, like in stop() in Applet. 87 | */ 88 | public GameController getGameController() { 89 | return this.gameController; 90 | } 91 | 92 | /** 93 | * This inner class will listen for presses on the "Start Game" button. 94 | * It will respond by creating a new game model and starting it using 95 | * the game controller. 96 | */ 97 | private class StartGameListener implements ActionListener { 98 | @Override 99 | public void actionPerformed(final ActionEvent e) { 100 | Object source = e.getSource(); 101 | 102 | if (source == GUIView.this.startGameButton) { 103 | // Get the name of the game selected in the Choice 104 | String gameName = 105 | GUIView.this.gameChooser.getSelectedItem().toString(); 106 | GameModel gameModel = 107 | GUIView.this.gameFactory.createGame(gameName); 108 | 109 | // Stop current game (if any) and start a new game with the 110 | // new game model 111 | GUIView.this.gameController.stopGame(); 112 | GUIView.this.gameController.startGame(gameModel); 113 | GUIView.this.gameView.requestFocus(); 114 | } 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/lab1/GameController.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | import java.awt.event.KeyAdapter; 4 | import java.awt.event.KeyEvent; 5 | import java.awt.event.KeyListener; 6 | import java.util.LinkedList; 7 | import java.util.List; 8 | 9 | /** 10 | * The controller class of the framework. Listens to user keystrokes and 11 | * passes them on to the current game. 12 | * 13 | */ 14 | public class GameController implements Runnable { 15 | 16 | /** The view this controller is connected to. */ 17 | private final GameView view; 18 | 19 | /** The game model describes the running game. */ 20 | private GameModel gameModel; 21 | 22 | /** The timeout interval between each update. (millis) */ 23 | private final int updateInterval; 24 | 25 | /** True when game is running. */ 26 | private boolean isRunning; 27 | 28 | /** Listener for key events to the game. */ 29 | private final KeyListener keyListener; 30 | 31 | /** A queue for all keypresses which so far haven't been processed */ 32 | private final List keypresses; 33 | 34 | /* 35 | * The declaration of keypresses above uses the language feature 'generic 36 | * types'. It can be declared in the old way like this: private 37 | * java.util.List keypresses This will however result in a warning at 38 | * compilation "Integer" in this case is the type of the objects that are 39 | * going to be used in the List 40 | */ 41 | 42 | /** The thread which the game runs in. */ 43 | private Thread gameThread; 44 | 45 | /** 46 | * Creats a new GameContoller associated with supplied view. 47 | */ 48 | public GameController(final GameView view) { 49 | this.view = view; 50 | this.gameModel = null; 51 | this.isRunning = false; 52 | this.updateInterval = 150; 53 | 54 | this.keypresses = new LinkedList(); 55 | 56 | this.gameThread = null; 57 | 58 | // Create the key listener which will listen for gamekeys 59 | this.keyListener = new KeyAdapter() { 60 | @SuppressWarnings("synthetic-access") 61 | @Override 62 | public void keyPressed(final KeyEvent event) { 63 | enqueueKeyPress(event.getKeyCode()); 64 | } 65 | }; 66 | 67 | } 68 | 69 | /** 70 | * Add a key press to the end of the queue 71 | */ 72 | private synchronized void enqueueKeyPress(final int key) { 73 | this.keypresses.add(Integer.valueOf(key)); 74 | } 75 | 76 | /** 77 | * Get a key press, and remove it from the queue. Returns 0 if no key press 78 | * is available. 79 | * 80 | * 81 | * @return 0 or next unprocessed key press. 82 | */ 83 | private synchronized int nextKeyPress() { 84 | if (this.keypresses.isEmpty()) { 85 | return 0; 86 | } 87 | return this.keypresses.remove(0).intValue(); 88 | } 89 | 90 | /** 91 | * Starts a new game. 92 | * 93 | * @param gameModel 94 | * Game to start 95 | */ 96 | public void startGame(final GameModel gameModel) { 97 | if (this.isRunning) { 98 | throw new IllegalStateException("Game is already running"); 99 | } 100 | 101 | // Start listening for key events 102 | this.view.addKeyListener(this.keyListener); 103 | 104 | // Tell the view what to paint... 105 | this.view.setModel(gameModel); 106 | 107 | // Actually start the game 108 | this.gameModel = gameModel; 109 | this.isRunning = true; 110 | 111 | // Create the new thread and start it... 112 | this.gameThread = new Thread(this); 113 | this.gameThread.start(); 114 | } 115 | 116 | /** 117 | * Stops the currently running game, if any. 118 | */ 119 | public void stopGame() { 120 | // Setting isRunning to false will 121 | // make the thread stop (see run()) 122 | this.isRunning = false; 123 | 124 | // Unset the game model... 125 | this.view.setModel(null); 126 | 127 | // Stop listening for events 128 | this.view.removeKeyListener(this.keyListener); 129 | 130 | // Make sure we wait until the thread has stopped... 131 | if (this.gameThread != null) { 132 | while (this.gameThread.isAlive()) { 133 | try { 134 | Thread.sleep(100); 135 | } catch (InterruptedException ie) { 136 | // Pass the call on. 137 | Thread.currentThread().interrupt(); 138 | } 139 | } 140 | } 141 | } 142 | 143 | /** 144 | * This code runs the game in a different thread. 145 | */ 146 | @Override 147 | public void run() { 148 | while (this.isRunning) { 149 | try { 150 | // Tell model to update, send next key press. 151 | // or 0 if no new keypress since last update. 152 | this.gameModel.gameUpdate(nextKeyPress()); 153 | 154 | this.view.repaint(); 155 | 156 | Thread.sleep(this.updateInterval); 157 | } catch (GameOverException e) { 158 | // we got a game over signal, time to exit... 159 | // The current implementation ignores the game score 160 | this.isRunning = false; 161 | System.out.println("Game over: " + e.getScore()); 162 | } catch (InterruptedException e) { 163 | // if we get this exception, we're asked to terminate ourselves 164 | this.isRunning = false; 165 | } 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /doc/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Deprecated List 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Deprecated API

84 |
85 |
86 | Contents
    87 |
88 | 89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 |
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /doc/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Constant Field Values 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Constant Field Values

84 |
85 |
86 | Contents
    87 |
88 | 89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 |
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /doc/lab1/class-use/Main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.Main 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.Main

84 |
85 | No usage of lab1.Main 86 |

87 |


88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 109 | 112 | 113 | 114 | 115 | 118 | 134 | 135 |
110 | 111 |
136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /doc/lab1/class-use/GUIView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.GUIView 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.GUIView

84 |
85 | No usage of lab1.GUIView 86 |

87 |


88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 109 | 112 | 113 | 114 | 115 | 118 | 134 | 135 |
110 | 111 |
136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /doc/lab1/class-use/GoldModel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.GoldModel 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.GoldModel

84 |
85 | No usage of lab1.GoldModel 86 |

87 |


88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 109 | 112 | 113 | 114 | 115 | 118 | 134 | 135 |
110 | 111 |
136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /doc/lab1/class-use/RoundTile.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.RoundTile 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.RoundTile

84 |
85 | No usage of lab1.RoundTile 86 |

87 |


88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 109 | 112 | 113 | 114 | 115 | 118 | 134 | 135 |
110 | 111 |
136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /doc/lab1/class-use/GameFactory.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.GameFactory 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.GameFactory

84 |
85 | No usage of lab1.GameFactory 86 |

87 |


88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 109 | 112 | 113 | 114 | 115 | 118 | 134 | 135 |
110 | 111 |
136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /doc/lab1/class-use/RectangularTile.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.RectangularTile 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.RectangularTile

84 |
85 | No usage of lab1.RectangularTile 86 |

87 |


88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 109 | 112 | 113 | 114 | 115 | 118 | 134 | 135 |
110 | 111 |
136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /doc/index-files/index-7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | L-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | L

83 |
84 |
lab1 - package lab1
 
85 |
86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 107 | 110 | 111 | 112 | 113 | 116 | 132 | 133 |
108 | 109 |
134 | 135 | 136 | 137 | C D E G H I L M P R S U V
138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /doc/index-files/index-5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | H-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | H

83 |
84 |
hashCode() - 85 | Method in class lab1.Position 86 |
  87 |
88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 110 | 113 | 114 | 115 | 116 | 119 | 135 | 136 |
111 | 112 |
137 | 138 | 139 | 140 | C D E G H I L M P R S U V
141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /doc/index-files/index-6.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | I-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | I

83 |
84 |
IGameFactory - Interface in lab1
Factory interface for available games.
85 |
86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 107 | 110 | 111 | 112 | 113 | 116 | 132 | 133 |
108 | 109 |
134 | 135 | 136 | 137 | C D E G H I L M P R S U V
138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /doc/index-files/index-3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | E-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | E

83 |
84 |
equals(Object) - 85 | Method in class lab1.Position 86 |
  87 |
88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 110 | 113 | 114 | 115 | 116 | 119 | 135 | 136 |
111 | 112 |
137 | 138 | 139 | 140 | C D E G H I L M P R S U V
141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /doc/index-files/index-12.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | U-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | U

83 |
84 |
update(Graphics) - 85 | Method in class lab1.GameView 86 |
This method ensures that the painting is performed double-buffered. 87 |
88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 110 | 113 | 114 | 115 | 116 | 119 | 135 | 136 |
111 | 112 |
137 | 138 | 139 | 140 | C D E G H I L M P R S U V
141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /doc/index-files/index-8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | M-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | M

83 |
84 |
Main - Class in lab1
This class creates an AWT window which will contain the game.
Main() - 85 | Constructor for class lab1.Main 86 |
  87 |
main(String[]) - 88 | Static method in class lab1.Main 89 |
  90 |
91 |
92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 113 | 116 | 117 | 118 | 119 | 122 | 138 | 139 |
114 | 115 |
140 | 141 | 142 | 143 | C D E G H I L M P R S U V
144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /doc/lab1/class-use/GameView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.GameView 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.GameView

84 |
85 | 86 | 87 | 88 | 90 | 91 |
89 | Uses of GameView in lab1
92 |   93 |

94 | 95 | 96 | 97 | 98 | 99 | 100 | 104 | 105 |
Constructors in lab1 with parameters of type GameView
GameController(GameView view) 101 | 102 |
103 |           Creats a new GameContoller associated with supplied view.
106 |   107 |

108 |


109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 130 | 133 | 134 | 135 | 136 | 139 | 155 | 156 |
131 | 132 |
157 | 158 | 159 | 160 |
161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /doc/index-files/index-1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | C-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | C

83 |
84 |
Constants - Enum in lab1
Provides a fixed size for various games.
createGame(String) - 85 | Method in class lab1.GameFactory 86 |
Returns a new model object for the game corresponding to its Name. 87 |
createGame(String) - 88 | Method in interface lab1.IGameFactory 89 |
Returns a new model object for the game corresponding to its Name. 90 |
91 |
92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 113 | 116 | 117 | 118 | 119 | 122 | 138 | 139 |
114 | 115 |
140 | 141 | 142 | 143 | C D E G H I L M P R S U V
144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /doc/index-files/index-9.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | P-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | P

83 |
84 |
paintComponent(Graphics) - 85 | Method in class lab1.GameView 86 |
Consults the model to paint the game matrix. 87 |
Position - Class in lab1
Immutable class describing integer 2D-points.
Position(int, int) - 88 | Constructor for class lab1.Position 89 |
Creates an immutable instance of a 2D integer coordinate. 90 |
91 |
92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 113 | 116 | 117 | 118 | 119 | 122 | 138 | 139 |
114 | 115 |
140 | 141 | 142 | 143 | C D E G H I L M P R S U V
144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /src/lab1/GoldModel.java: -------------------------------------------------------------------------------- 1 | package lab1; 2 | 3 | import java.awt.Color; 4 | import java.awt.Dimension; 5 | import java.awt.event.KeyEvent; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Sample game for illustration. Intentionally stupid; more interesting 11 | * games to be provided by students. 12 | *

13 | * Initially 20 gold coins are randomly placed in the matrix. The red gold 14 | * collector aims to collect these coins which disappear after collection. Each 15 | * coin is randomly moved to a new position every n moves, where n is the number 16 | * of remaining coins. The game is won when all coins are collected and lost when 17 | * collector leaves game board. 18 | */ 19 | public class GoldModel extends GameModel { 20 | public enum Directions { 21 | EAST(1, 0), 22 | WEST(-1, 0), 23 | NORTH(0, -1), 24 | SOUTH(0, 1), 25 | NONE(0, 0); 26 | 27 | private final int xDelta; 28 | private final int yDelta; 29 | 30 | Directions(final int xDelta, final int yDelta) { 31 | this.xDelta = xDelta; 32 | this.yDelta = yDelta; 33 | } 34 | 35 | public int getXDelta() { 36 | return this.xDelta; 37 | } 38 | 39 | public int getYDelta() { 40 | return this.yDelta; 41 | } 42 | } 43 | 44 | 45 | 46 | private static final int COIN_START_AMOUNT = 20; 47 | 48 | /* 49 | * The following GameTile objects are used only 50 | * to describe how to paint the specified item. 51 | * 52 | * This means that they should only be used in 53 | * conjunction with the get/setGameboardState() 54 | * methods. 55 | */ 56 | 57 | /** Graphical representation of a coin. */ 58 | private static final GameTile COIN_TILE = new RoundTile(new Color(255, 215, 59 | 0), 60 | new Color(255, 255, 0), 2.0); 61 | 62 | 63 | 64 | /** Graphical representation of the collector */ 65 | private static final GameTile COLLECTOR_TILE = new RoundTile(Color.BLACK, 66 | Color.RED, 2.0); 67 | 68 | /** Graphical representation of a blank tile. */ 69 | private static final GameTile BLANK_TILE = new GameTile(); 70 | 71 | /** A list containing the positions of all coins. */ 72 | private final List coins = new ArrayList(); 73 | /* 74 | * The declaration and object creation above uses the new language feature 75 | * 'generic types'. It can be declared in the old way like this: 76 | * private java.util.List coins = new ArrayList(); 77 | * This will however result in a warning at compilation 78 | * "Position" in this case is the type of the objects that are going 79 | * to be used in the List 80 | */ 81 | 82 | /** The position of the collector. */ 83 | private Position collectorPos; 84 | 85 | /** The direction of the collector. */ 86 | private Directions direction = Directions.NORTH; 87 | 88 | /** The number of coins found. */ 89 | private int score; 90 | 91 | /** 92 | * Create a new model for the gold game. 93 | */ 94 | public GoldModel() { 95 | Dimension size = getGameboardSize(); 96 | 97 | // Blank out the whole gameboard 98 | for (int i = 0; i < size.width; i++) { 99 | for (int j = 0; j < size.height; j++) { 100 | setGameboardState(i, j, BLANK_TILE); 101 | } 102 | } 103 | 104 | // Insert the collector in the middle of the gameboard. 105 | this.collectorPos = new Position(size.width / 2, size.height / 2); 106 | setGameboardState(this.collectorPos, COLLECTOR_TILE); 107 | 108 | // Insert coins into the gameboard. 109 | for (int i = 0; i < COIN_START_AMOUNT; i++) { 110 | addCoin(); 111 | } 112 | } 113 | 114 | /** 115 | * Insert another coin into the gameboard. 116 | */ 117 | private void addCoin() { 118 | Position newCoinPos; 119 | Dimension size = getGameboardSize(); 120 | // Loop until a blank position is found and ... 121 | do { 122 | newCoinPos = new Position((int) (Math.random() * size.width), 123 | (int) (Math.random() * size.height)); 124 | } while (!isPositionEmpty(newCoinPos)); 125 | 126 | // ... add a new coin to the empty tile. 127 | setGameboardState(newCoinPos, COIN_TILE); 128 | this.coins.add(newCoinPos); 129 | } 130 | 131 | /** 132 | * Return whether the specified position is empty. 133 | * 134 | * @param pos 135 | * The position to test. 136 | * @return true if position is empty. 137 | */ 138 | private boolean isPositionEmpty(final Position pos) { 139 | return (getGameboardState(pos) == BLANK_TILE); 140 | } 141 | 142 | /** 143 | * Update the direction of the collector 144 | * according to the user's keypress. 145 | */ 146 | private void updateDirection(final int key) { 147 | switch (key) { 148 | case KeyEvent.VK_LEFT: 149 | this.direction = Directions.WEST; 150 | break; 151 | case KeyEvent.VK_UP: 152 | this.direction = Directions.NORTH; 153 | break; 154 | case KeyEvent.VK_RIGHT: 155 | this.direction = Directions.EAST; 156 | break; 157 | case KeyEvent.VK_DOWN: 158 | this.direction = Directions.SOUTH; 159 | 160 | break; 161 | default: 162 | // Don't change direction if another key is pressed 163 | break; 164 | } 165 | } 166 | 167 | /** 168 | * Get next position of the collector. 169 | */ 170 | private Position getNextCollectorPos() { 171 | return new Position( 172 | this.collectorPos.getX() + this.direction.getXDelta(), 173 | this.collectorPos.getY() + this.direction.getYDelta()); 174 | } 175 | 176 | /** 177 | * This method is called repeatedly so that the 178 | * game can update its state. 179 | * 180 | * @param lastKey 181 | * The most recent keystroke. 182 | */ 183 | @Override 184 | public void gameUpdate(final int lastKey) throws GameOverException { 185 | updateDirection(lastKey); 186 | 187 | // Erase the previous position. 188 | setGameboardState(this.collectorPos, BLANK_TILE); 189 | // Change collector position. 190 | this.collectorPos = getNextCollectorPos(); 191 | 192 | if (isOutOfBounds(this.collectorPos)) { 193 | throw new GameOverException(this.score); 194 | } 195 | // Draw collector at new position. 196 | setGameboardState(this.collectorPos, COLLECTOR_TILE); 197 | 198 | // Remove the coin at the new collector position (if any) 199 | if (this.coins.remove(this.collectorPos)) { 200 | this.score+=2; 201 | } 202 | 203 | // Check if all coins are found 204 | if (this.coins.isEmpty()) { 205 | throw new GameOverException(this.score + 5); 206 | } 207 | 208 | // Remove one of the coins 209 | Position oldCoinPos = this.coins.get(0); 210 | this.coins.remove(0); 211 | setGameboardState(oldCoinPos, BLANK_TILE); 212 | 213 | // Add a new coin (simulating moving one coin) 214 | addCoin(); 215 | 216 | } 217 | 218 | /** 219 | * 220 | * @param pos The position to test. 221 | * @return false if the position is outside the playing field, true otherwise. 222 | */ 223 | private boolean isOutOfBounds(Position pos) { 224 | return pos.getX() < 0 || pos.getX() >= getGameboardSize().width 225 | || pos.getY() < 0 || pos.getY() >= getGameboardSize().height; 226 | } 227 | 228 | public int getScore(){ 229 | return this.score; 230 | } 231 | 232 | } 233 | -------------------------------------------------------------------------------- /doc/lab1/class-use/GameController.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.GameController 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |


29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.GameController

84 |
85 | 86 | 87 | 88 | 90 | 91 |
89 | Uses of GameController in lab1
92 |   93 |

94 | 95 | 96 | 97 | 98 | 99 | 100 | 102 | 106 | 107 |
Methods in lab1 that return GameController
101 |  GameControllerGUIView.getGameController() 103 | 104 |
105 |           Get a reference to the game controller.
108 |   109 |

110 |


111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 132 | 135 | 136 | 137 | 138 | 141 | 157 | 158 |
133 | 134 |
159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /doc/lab1/class-use/Position.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.Position 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.Position

84 |
85 | 86 | 87 | 88 | 90 | 91 |
89 | Uses of Position in lab1
92 |   93 |

94 | 95 | 96 | 97 | 98 | 99 | 100 | 102 | 106 | 107 |
Methods in lab1 with parameters of type Position
101 |  GameTileGameModel.getGameboardState(Position pos) 103 | 104 |
105 |           Returns the GameTile in logical position (x,y) of the gameboard.
108 |   109 |

110 |


111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 132 | 135 | 136 | 137 | 138 | 141 | 157 | 158 |
133 | 134 |
159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /doc/index-files/index-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | D-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | D

83 |
84 |
draw(Graphics, int, int, Dimension) - 85 | Method in class lab1.GameTile 86 |
Draws itself in a given graphics context, position and size. 87 |
draw(Graphics, int, int, Dimension) - 88 | Method in class lab1.RectangularTile 89 |
Draws itself in a given graphics context, position and size. 90 |
draw(Graphics, int, int, Dimension) - 91 | Method in class lab1.RoundTile 92 |
Draws itself in a given graphics context, position and size. 93 |
94 |
95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 116 | 119 | 120 | 121 | 122 | 125 | 141 | 142 |
117 | 118 |
143 | 144 | 145 | 146 | C D E G H I L M P R S U V
147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /doc/index-files/index-11.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | S-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | S

83 |
84 |
setModel(GameModel) - 85 | Method in class lab1.GameView 86 |
Updates the view with a new model. 87 |
SIZE - 88 | Static variable in enum lab1.Constants 89 |
An immutable Dimension object of constant size. 90 |
startGame(GameModel) - 91 | Method in class lab1.GameController 92 |
Starts a new game. 93 |
stopGame() - 94 | Method in class lab1.GameController 95 |
Stops the currently running game, if any. 96 |
97 |
98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 119 | 122 | 123 | 124 | 125 | 128 | 144 | 145 |
120 | 121 |
146 | 147 | 148 | 149 | C D E G H I L M P R S U V
150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /doc/index-files/index-13.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | V-Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 | C D E G H I L M P R S U V
81 |

82 | V

83 |
84 |
valueOf(String) - 85 | Static method in enum lab1.Constants 86 |
Returns the enum constant of this type with the specified name. 87 |
valueOf(String) - 88 | Static method in enum lab1.GoldModel.Directions 89 |
Returns the enum constant of this type with the specified name. 90 |
values() - 91 | Static method in enum lab1.Constants 92 |
Returns an array containing the constants of this enum type, in 93 | the order they are declared. 94 |
values() - 95 | Static method in enum lab1.GoldModel.Directions 96 |
Returns an array containing the constants of this enum type, in 97 | the order they are declared. 98 |
99 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 121 | 124 | 125 | 126 | 127 | 130 | 146 | 147 |
122 | 123 |
148 | 149 | 150 | 151 | C D E G H I L M P R S U V
152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /doc/lab1/class-use/GameOverException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.GameOverException 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.GameOverException

84 |
85 | 86 | 87 | 88 | 90 | 91 |
89 | Uses of GameOverException in lab1
92 |   93 |

94 | 95 | 96 | 97 | 98 | 99 | 100 | 102 | 106 | 107 | 108 | 110 | 115 | 116 |
Methods in lab1 that throw GameOverException
101 | abstract  voidGameModel.gameUpdate(int lastKey) 103 | 104 |
105 |           This method is called repeatedly so that the game can update it's state.
109 |  voidGoldModel.gameUpdate(int lastKey) 111 | 112 |
113 |           This method is called repeatedly so that the 114 | game can update its state.
117 |   118 |

119 |


120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 141 | 144 | 145 | 146 | 147 | 150 | 166 | 167 |
142 | 143 |
168 | 169 | 170 | 171 |
172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /doc/lab1/class-use/Constants.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.Constants 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.Constants

84 |
85 | 86 | 87 | 88 | 90 | 91 |
89 | Uses of Constants in lab1
92 |   93 |

94 | 95 | 96 | 97 | 98 | 99 | 100 | 102 | 106 | 107 | 108 | 110 | 115 | 116 |
Methods in lab1 that return Constants
101 | static ConstantsConstants.valueOf(java.lang.String name) 103 | 104 |
105 |           Returns the enum constant of this type with the specified name.
109 | static Constants[]Constants.values() 111 | 112 |
113 |           Returns an array containing the constants of this enum type, in 114 | the order they are declared.
117 |   118 |

119 |


120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 141 | 144 | 145 | 146 | 147 | 150 | 166 | 167 |
142 | 143 |
168 | 169 | 170 | 171 |
172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /doc/lab1/class-use/IGameFactory.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Interface lab1.IGameFactory 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Interface
lab1.IGameFactory

84 |
85 | 86 | 87 | 88 | 90 | 91 |
89 | Uses of IGameFactory in lab1
92 |   93 |

94 | 95 | 96 | 97 | 98 | 99 | 100 | 102 | 106 | 107 |
Classes in lab1 that implement IGameFactory
101 |  classGameFactory 103 | 104 |
105 |           Factory class for available games.
108 |   109 |

110 | 111 | 112 | 113 | 114 | 115 | 116 | 120 | 121 |
Constructors in lab1 with parameters of type IGameFactory
GUIView(IGameFactory factory) 117 | 118 |
119 |           Create a new GUIView.
122 |   123 |

124 |


125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 146 | 149 | 150 | 151 | 152 | 155 | 171 | 172 |
147 | 148 |
173 | 174 | 175 | 176 |
177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /doc/lab1/class-use/GoldModel.Directions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class lab1.GoldModel.Directions 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Uses of Class
lab1.GoldModel.Directions

84 |
85 | 86 | 87 | 88 | 90 | 91 |
89 | Uses of GoldModel.Directions in lab1
92 |   93 |

94 | 95 | 96 | 97 | 98 | 99 | 100 | 102 | 106 | 107 | 108 | 110 | 115 | 116 |
Methods in lab1 that return GoldModel.Directions
101 | static GoldModel.DirectionsGoldModel.Directions.valueOf(java.lang.String name) 103 | 104 |
105 |           Returns the enum constant of this type with the specified name.
109 | static GoldModel.Directions[]GoldModel.Directions.values() 111 | 112 |
113 |           Returns an array containing the constants of this enum type, in 114 | the order they are declared.
117 |   118 |

119 |


120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 141 | 144 | 145 | 146 | 147 | 150 | 166 | 167 |
142 | 143 |
168 | 169 | 170 | 171 |
172 | 173 | 174 | 175 | --------------------------------------------------------------------------------