diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..07c02d9
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..dfca8c4
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..3327723
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..e357e55
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,998 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1464343119516
+
+
+ 1464343119516
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Miner.iml b/Miner.iml
new file mode 100644
index 0000000..73f608b
--- /dev/null
+++ b/Miner.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..ce5a2ab
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,29 @@
+
+
+ 4.0.0
+
+ ru.Antony
+ Miner
+ 1.0-SNAPSHOT
+ jar
+ Miner
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.4
+
+
+
+ miner.AppMain
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/logic/GameLogic.java b/src/main/java/logic/GameLogic.java
new file mode 100644
index 0000000..3dceddf
--- /dev/null
+++ b/src/main/java/logic/GameLogic.java
@@ -0,0 +1,213 @@
+package logic;
+
+import miner.ICell;
+import miner.IGameLogic;
+import miner.IMineField;
+import miner.IUserInterface;
+import java.util.Random;
+
+enum Status {BEGIN, WIN, LOSE};
+
+/**
+ * Created by Antony on 25.05.2016.
+ */
+public class GameLogic implements IGameLogic{
+
+ private final int MINESFIELD_HEIGHT;
+ private final int MINESFIELD_WIDTH;
+ private final int MINES_NUMBER ;
+
+ private IUserInterface userInterface;
+
+ private IMineField mineField;
+ private ICell[][] cells;
+ private Status s;
+ private int flagsCounter ; //number of flags to mark mines
+
+
+ public GameLogic()
+ {
+ MINESFIELD_HEIGHT = IGameLogic.MINEFIELD_HEIGHT;
+ MINESFIELD_WIDTH = IGameLogic.MINEFIELD_WIDTH;
+ MINES_NUMBER = IGameLogic.MINES_NUMBER;
+
+ flagsCounter = MINES_NUMBER;
+ }
+
+ public void setUserInterface(IUserInterface ui)
+ {
+ userInterface = ui;
+ }
+
+ public int getMinesNumber()
+ {
+ return MINES_NUMBER;
+ }
+
+ public int getFlagsNumber() { return flagsCounter;}
+
+ public int getHeight()
+ {
+ return MINESFIELD_HEIGHT;
+ }
+
+ public int getWidth()
+ {
+ return MINESFIELD_WIDTH;
+ }
+
+
+ /**
+ * This method puts mines into the mining field
+ * @param mf the mining field to be put mines on it
+ */
+ public void setMines(IMineField mf)
+ {
+ if (cells == null) {
+ cells = mf.getCells();
+ }
+ if (cells != null) {
+ int mines = 0;
+
+ Random rand = new Random();
+
+ do {
+ int row = rand.nextInt(MINESFIELD_HEIGHT);
+ int col = rand.nextInt(MINESFIELD_WIDTH);
+
+ if (!cells[row][col].isBomb()) {
+ cells[row][col].setIsBomb(true);
+
+ //surrounding cells with numbers
+ if (row != 0 && col != 0)
+ cells[row - 1][col - 1].setNeibourMinesQty(cells[row - 1][col - 1].getNeibourMinesQty() + 1);
+ if (row != 0) cells[row - 1][col].setNeibourMinesQty(cells[row - 1][col].getNeibourMinesQty() + 1);
+ if (row != 0 && col != MINESFIELD_WIDTH - 1)
+ cells[row - 1][col + 1].setNeibourMinesQty(cells[row - 1][col + 1].getNeibourMinesQty() + 1);
+ if (col != 0) cells[row][col - 1].setNeibourMinesQty(cells[row][col - 1].getNeibourMinesQty() + 1);
+ if (col != MINESFIELD_WIDTH - 1)
+ cells[row][col + 1].setNeibourMinesQty(cells[row][col + 1].getNeibourMinesQty() + 1);
+ if (row != MINESFIELD_HEIGHT - 1 && col != 0)
+ cells[row + 1][col - 1].setNeibourMinesQty(cells[row + 1][col - 1].getNeibourMinesQty() + 1);
+ if (row != MINESFIELD_HEIGHT - 1)
+ cells[row + 1][col].setNeibourMinesQty(cells[row + 1][col].getNeibourMinesQty() + 1);
+ if (row != MINESFIELD_HEIGHT - 1 && col != MINESFIELD_WIDTH - 1)
+ cells[row + 1][col + 1].setNeibourMinesQty(cells[row + 1][col + 1].getNeibourMinesQty() + 1);
+ mines++;
+ }
+ }
+ while (mines != MINES_NUMBER);
+ }
+ else
+ {
+ userInterface.showErrorMessage("Возникла ошибка в процессе растановки мин.");
+ }
+ }
+
+ /**
+ * This method opens the cells in the Mining Field
+ * @param row
+ * @param col
+ */
+ public void OpenCell(int row, int col, boolean flag)
+ {
+ if (s == Status.WIN || s == Status.LOSE) return;
+
+ if(cells == null) {
+ cells = mineField.getCells();
+ }
+ if (cells == null) return;
+
+ //If user pressed Left mouse button
+ if(flag == false) {
+
+ if (cells[row][col].isFlag()) return;
+
+ if (!cells[row][col].isUncovered() && cells[row][col].isBomb()) {
+ s = Status.LOSE;
+ mineField.BlastAllBombs();
+ userInterface.lose();
+ } else {
+
+ if (!cells[row][col].isUncovered() && cells[row][col].getNeibourMinesQty() == 0) {
+ cells[row][col].setIsUncovered(true);
+
+
+ OpenSurroundingCells(row, col);
+ } else if (!cells[row][col].isUncovered() && cells[row][col].getNeibourMinesQty() != 0) {
+ cells[row][col].setIsUncovered(true);
+ }
+ }
+ }
+ // if user has pressed right button
+ else
+ {
+ if (!cells[row][col].isFlag())
+ {
+ cells[row][col].setIsFlag(true);
+ flagsCounter--;
+ }
+ else
+ {
+ cells[row][col].setIsFlag(false);
+ flagsCounter++;
+ }
+ }
+
+ mineField.drawCells();
+
+ if (checkVictory())
+ {
+ s = Status.WIN;
+ userInterface.win();
+ }
+ }
+
+ /**
+ * This method calculates the opening of surrounding cells
+ * @param row - rows
+ * @param col - columns
+ */
+ private void OpenSurroundingCells(int row, int col)
+ {
+ // открыть примыкающие клетки слева, справа, сверху, снизу
+ if (col != 0) this.OpenCell(row, col - 1, false);
+ if (row != 0) this.OpenCell(row - 1, col, false);
+ if (col != MINESFIELD_WIDTH - 1) this.OpenCell(row, col + 1, false);
+ if (row != MINESFIELD_HEIGHT - 1) this.OpenCell(row + 1, col, false);
+
+ //примыкающие диагонально
+ if (row != 0 && col != 0) this.OpenCell(row - 1, col - 1, false);
+ if (row != 0 && col != MINESFIELD_WIDTH - 1) this.OpenCell(row - 1, col + 1, false);
+ if (row != MINESFIELD_HEIGHT - 1 && col != 0) this.OpenCell(row + 1, col - 1, false);
+ if (row != MINESFIELD_HEIGHT - 1 && col != MINESFIELD_WIDTH - 1) this.OpenCell(row + 1, col + 1, false);
+
+ }
+
+ public void initGame()
+ {
+ if (mineField != null)
+ {
+ s = Status.BEGIN;
+ mineField.createCells();
+ setMines(mineField);
+ flagsCounter = MINES_NUMBER;
+ }
+ }
+
+ public void setMineField(IMineField mf)
+ {
+ mineField = mf;
+ }
+
+ public boolean checkVictory()
+ {
+ int minesWithFlag = 0; // number of mines that are found
+
+ for (int row = 0; row < MINESFIELD_HEIGHT; row++)
+ for (int col = 0; col < MINESFIELD_WIDTH; col++)
+ if (cells[row][col].isBomb() && cells[row][col].isFlag()) minesWithFlag++;
+
+ return (minesWithFlag == MINES_NUMBER ? true : false);
+ }
+}
diff --git a/src/main/java/miner/AppMain.java b/src/main/java/miner/AppMain.java
new file mode 100644
index 0000000..f597f74
--- /dev/null
+++ b/src/main/java/miner/AppMain.java
@@ -0,0 +1,20 @@
+package miner;
+
+import miner.GUI.*;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class AppMain {
+
+ public static void main(String[] args) {
+ EventQueue.invokeLater(new Runnable() {
+
+ public void run() {
+ MainFrame mf = new MainFrame();
+ mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ mf.setVisible(true);
+ }
+ });
+ }
+}
diff --git a/src/main/java/miner/GUI/Cell.java b/src/main/java/miner/GUI/Cell.java
new file mode 100644
index 0000000..670d91c
--- /dev/null
+++ b/src/main/java/miner/GUI/Cell.java
@@ -0,0 +1,131 @@
+package miner.GUI;
+
+import miner.ICell;
+
+import javax.swing.*;
+import java.awt.*;
+
+
+
+/**
+ * Created by Antony on 25.05.2016.
+ */
+public class Cell extends JLabel implements ICell {
+//public class Cell implements ICell {
+ //private CellStatus cellStatus;
+
+ public static int CELLSIZE = 30;
+ public static Color CELLBORDERCOLOR = Color.BLACK;
+ public static Color UNCKECKEDCOLOR = new Color(181, 230, 29);
+ public static Color UNCOVEREDCOLOR = new Color(231, 235, 65);
+
+ private boolean uncovered;
+ private boolean flag;
+ private boolean bomb;
+ private int neibourMinesQty = 0;
+
+
+
+ public Cell()
+ {
+ //this.cellStatus = CellStatus.UNCHECKED;
+ this.uncovered = false;
+ this.flag = false;
+ this.bomb = false;
+
+ setPreferredSize(new Dimension(CELLSIZE, CELLSIZE));
+ drawCell();
+ }
+
+ @Override
+ public boolean isBomb() {
+ return bomb;
+ }
+
+ @Override
+ public boolean isFlag() {
+ return flag;
+ }
+
+ @Override
+ public boolean isUncovered() {
+ return uncovered;
+ }
+
+ @Override
+ public void setIsBomb(boolean b) {
+ bomb = b;
+ }
+
+ @Override
+ public void setIsFlag(boolean b) {
+ flag = b;
+ }
+
+ @Override
+ public void setIsUncovered(boolean b) {
+ uncovered = b;
+ }
+
+ @Override
+ public void setNeibourMinesQty(int i) {
+ neibourMinesQty = i;
+ }
+
+ @Override
+ public int getNeibourMinesQty() {
+ return neibourMinesQty ;
+ }
+
+ //public void DrawCell(int x , int y)
+ public void drawCell() {
+ setBorder(BorderFactory.createLineBorder(CELLBORDERCOLOR));
+
+ if (!uncovered) {
+ setText("");
+
+ setOpaque(true);
+ setBackground(UNCKECKEDCOLOR);
+
+ if (flag)
+ {
+ drawFlag();
+ }
+
+ } else if (uncovered) {
+ if (!isBomb()) {
+ setOpaque(true);
+ setBackground(UNCOVEREDCOLOR);
+ if (neibourMinesQty != 0) {
+ setNeighbourNumbers();
+ }
+
+ }
+ }
+
+ if (uncovered && isBomb()) {
+ drawBomb();
+ }
+ }
+
+ /**
+ * here we can draw a bomb in any way we like
+ */
+ public void drawBomb()
+ {
+ setOpaque(true);
+ setBackground(Color.RED);
+ }
+
+ public void setNeighbourNumbers()
+ {
+ setHorizontalAlignment(CENTER);
+ setText("" + neibourMinesQty);
+ }
+
+ public void drawFlag()
+ {
+ setHorizontalAlignment(CENTER);
+ setText("F");
+ }
+}
diff --git a/src/main/java/miner/GUI/MainFrame.java b/src/main/java/miner/GUI/MainFrame.java
new file mode 100644
index 0000000..018dcbe
--- /dev/null
+++ b/src/main/java/miner/GUI/MainFrame.java
@@ -0,0 +1,132 @@
+/**
+ * Этот класс представляет собой окно приложения с игрой и является интерфесом, -
+ * Класс содержит объект gameLogic
+ */
+
+package miner.GUI;
+
+/**
+ * Created by Antony on 25.05.2016.
+ */
+
+import logic.GameLogic;
+import miner.IGameLogic;
+import miner.IUserInterface;
+
+import javax.swing.*;
+import java.awt.*;
+
+
+
+public class MainFrame extends JFrame implements IUserInterface {
+ private static int WIDTH = 400;
+ private static int HEIGHT = 400;
+
+ private IGameLogic game;
+ private UserAction listener;
+ private JLabel lblMinesCount;
+
+ private MineField mineField;
+
+
+ public MainFrame()
+ {
+ this("Miner", WIDTH, HEIGHT);
+ }
+
+ /**
+ * Constructor with 3 patameters
+ * @param title - title for the application frame
+ * @param width
+ * @param height
+ */
+ public MainFrame(String title, int width, int height)
+ {
+ super(title);
+ setSize(width, height);
+ SetFrameOnCenter(this);
+
+ StartGame();
+ listener = new UserAction(game, this);
+ mineField.addMouseListener(listener);
+ addStartGameMenu();
+ addControls();
+
+ setResizable(false);
+ pack();
+
+ }
+
+ /**
+ * Метод создает объект типа GameLogic
+ * а так же минное поле (MineField), при создании которого в конструктор
+ * передается размеры минного поля, определенные в логике игры (gameLogic)
+ * После создания минное поля (MineField) ссылка на этот объект передается
+ * в объект gameLogic и вызвается метод initGame объекта gameLogic
+ */
+ public void StartGame()
+ {
+ game = new GameLogic();
+ game.setUserInterface(this);
+ mineField = new MineField(game.getHeight(), game.getWidth());
+ game.setMineField(mineField);
+ game.initGame();
+ }
+
+ /**
+ * Puts a Frame on the Center of the Screen
+ * @param f is a Frame
+ */
+ public void SetFrameOnCenter(JFrame f) {
+ Dimension us = f.getSize();
+ Dimension them = Toolkit.getDefaultToolkit().getScreenSize();
+ int newX = (them.width - us.width) / 2;
+ int newY = (them.height - us.height) / 2;
+ f.setLocation(newX, newY);
+ }
+
+ private void addStartGameMenu()
+ {
+ JMenuBar aMenuBar = new JMenuBar();
+ JMenuItem aMenuItem = new JMenuItem("Start new game");
+ aMenuItem.setActionCommand("aMenuItem");
+ aMenuItem.addActionListener(listener);
+
+ aMenuBar.add(aMenuItem);
+ this.setJMenuBar(aMenuBar);
+ }
+
+ private void addControls()
+ {
+ Container c = this.getContentPane();
+ c.add(mineField, BorderLayout.CENTER);
+
+ JPanel statusPanel = new JPanel();
+ lblMinesCount = new JLabel();
+ setStatusText(game.getMinesNumber());
+
+ statusPanel.setLayout(new BorderLayout());
+ statusPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ statusPanel.add(lblMinesCount, BorderLayout.WEST);
+
+ c.add(statusPanel, BorderLayout.SOUTH);
+
+ }
+
+ public void win() { JOptionPane.showMessageDialog(null, "You win!."); }
+
+ public void lose() {
+ JOptionPane.showMessageDialog(null, "Boom!, You lose.");
+ }
+
+ public void showErrorMessage(String s)
+ {
+ JOptionPane.showMessageDialog(null, s);
+ }
+
+ public void setStatusText(int flagsLeft)
+ {
+ lblMinesCount.setText(flagsLeft + " Mines left");
+ }
+
+}
diff --git a/src/main/java/miner/GUI/MineField.java b/src/main/java/miner/GUI/MineField.java
new file mode 100644
index 0000000..ea3801e
--- /dev/null
+++ b/src/main/java/miner/GUI/MineField.java
@@ -0,0 +1,103 @@
+/**
+ * этот класс описывает минное поле
+ * Он наследует интерфейс IMineField которое описывает поведение минного поля
+ */
+
+package miner.GUI;
+
+import miner.*;
+import javax.swing.*;
+import java.awt.*;
+
+
+/**
+ * Created by Antony on 25.05.2016.
+ */
+
+public class MineField extends JPanel implements IMineField {
+
+ //a table of minefield
+ private ICell[][] cells = null;
+
+ private int height; // a height of minefield
+ private int width; // a width of minefield
+
+ public MineField(int h, int w) {
+ this.height = h;
+ this.width = w;
+
+ setPreferredSize(new Dimension(width * Cell.CELLSIZE, height * Cell.CELLSIZE));
+ setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
+ }
+
+ /**
+ * Данный метод создаёт таблицу (матрицу) объектов ICell - ячеек на минном поле
+ * А если таблица уже создана (когда пользователь начинает новую игру)
+ * обновляет значения полей в объекте ICell на начальные
+ */
+ public void createCells()
+ {
+ if (cells ==null) {
+ cells = new Cell[height][width];
+ }
+
+ for (int x = 0; x < height; x++) {
+ for (int y = 0; y < width; y++) {
+ if (cells[x][y] == null) {
+ cells[x][y] = new Cell();
+ this.add((Cell) cells[x][y]);
+ }
+ else {
+ cells[x][y].setIsUncovered(false);
+ cells[x][y].setIsBomb(false);
+ cells[x][y].setIsFlag(false);
+ cells[x][y].setNeibourMinesQty(0);
+ }
+ }
+ }
+ drawCells();
+ }
+
+ /**
+ * Метод "отображает" ячейки
+ */
+ public void drawCells() {
+ for (int x = 0; x < height; x++)
+ {
+ for (int y = 0; y < width; y++)
+ {
+ cells[x][y].drawCell();
+ }
+ }
+ }
+
+ /**
+ * Метод отображает все бомбы (мины) взорванными
+ * т.е. показывает все мины когда проигрывает пользователь
+ */
+ public void BlastAllBombs()
+ {
+ for (int x = 0; x < height; x++)
+ {
+ for (int y = 0; y < width; y++)
+ {
+ if (cells[x][y].isBomb()) {
+ cells[x][y].setIsUncovered(true);
+ cells[x][y].drawCell();
+ }
+ }
+ }
+ }
+
+ /**
+ * Метод возвращает "таблицу" (2-у мерный массив) объектов ICell
+ * Класс требуется для доступа класса, описывающий логику игры
+ *
+ * @return ICell[][] 2-умерный массив ячеек на минном поле
+ */
+ public ICell[][] getCells()
+ {
+ return cells;
+ }
+
+}
diff --git a/src/main/java/miner/GUI/UserAction.java b/src/main/java/miner/GUI/UserAction.java
new file mode 100644
index 0000000..858efa2
--- /dev/null
+++ b/src/main/java/miner/GUI/UserAction.java
@@ -0,0 +1,71 @@
+/**
+ * Этот класс для взаимодействия пользователя с окном программы и
+ * минным полем..
+ */
+
+package miner.GUI;
+
+import miner.IGameLogic;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+
+/**
+ * Created by Antony on 25.05.2016.
+ */
+public class UserAction implements ActionListener, MouseListener {
+
+ private IGameLogic game;
+ private MainFrame app;
+
+ public UserAction(IGameLogic gl, MainFrame frame)
+ {
+ game = gl;
+ app = frame;
+ }
+
+ /**
+ * Обработчик нажатия кнопки
+ * @param e
+ */
+ public void actionPerformed(ActionEvent e) {
+
+ game.initGame();
+ app.setStatusText(game.getFlagsNumber());
+ }
+
+ /**
+ * Обработчик события нажатия кнопки мыши
+ *
+ * @param e с помощью параметра e мы определяем,
+ * какая кнопка была нажата
+ */
+
+ public void mouseClicked(MouseEvent e) {
+ int y = e.getX() / Cell.CELLSIZE;
+ int x = e.getY() / Cell.CELLSIZE;
+ boolean flag = (e.getButton() == MouseEvent.BUTTON3) ? true: false;
+ game.OpenCell(x, y , flag);
+
+ if (flag) app.setStatusText(game.getFlagsNumber());
+ }
+
+ public void mousePressed(MouseEvent e) {
+
+ }
+
+ public void mouseReleased(MouseEvent e) {
+
+ }
+
+ public void mouseEntered(MouseEvent e) {
+
+ }
+
+
+ public void mouseExited(MouseEvent e) {
+
+ }
+
+}
diff --git a/src/main/java/miner/ICell.java b/src/main/java/miner/ICell.java
new file mode 100644
index 0000000..6413256
--- /dev/null
+++ b/src/main/java/miner/ICell.java
@@ -0,0 +1,36 @@
+/**
+ * Интерфейс описывает поведение ячейки на минном поле
+ */
+
+package miner;
+
+/**
+ * Created by Antony on 25.05.2016.
+ */
+
+
+public interface ICell {
+
+ boolean isBomb();
+ boolean isFlag();
+ boolean isUncovered();
+
+ void setIsBomb(boolean b);
+ void setIsFlag(boolean b);
+ void setIsUncovered(boolean b);
+
+ void setNeibourMinesQty(int i);
+ int getNeibourMinesQty();
+
+ /**
+ * Draw/redraw a cell on a minefield
+ */
+ void drawCell();
+
+ /**
+ * Draw a bomb in anyway you like
+ */
+ void drawBomb();
+
+ void drawFlag();
+}
diff --git a/src/main/java/miner/IGameLogic.java b/src/main/java/miner/IGameLogic.java
new file mode 100644
index 0000000..51d0408
--- /dev/null
+++ b/src/main/java/miner/IGameLogic.java
@@ -0,0 +1,66 @@
+/**
+ * Интерфес описывает логику игры
+ */
+
+package miner;
+
+
+/**
+ * Created by Antony on 25.05.2016.
+ */
+public interface IGameLogic {
+
+ //easy level 8 x 8 and 10 bombs
+ int MINEFIELD_HEIGHT = 8;
+ int MINEFIELD_WIDTH = 8;
+ int MINES_NUMBER = 10;
+
+ /**
+ * Get number of mines in a game
+ * @return int - value of bombs in a game
+ */
+ int getMinesNumber();
+ int getFlagsNumber();
+
+ int getHeight();
+ int getWidth();
+
+ void setMineField(IMineField mf);
+
+ void initGame();
+
+ /**
+ * Метод устанавливает мины на минном поле
+ * @param mf - объект типа IMineField - минное поле, на котором утанавиливаются мины
+ */
+ void setMines(IMineField mf);
+
+ /**
+ * метод описывающий что происходи при открытии ячейки
+ * или пометки ее флажком
+ *
+ * @param row - ряд в таблице ячеек на минном поле
+ * @param col - колонка в таблице ячеек на минном поле
+ * @param flag - устанавливается флаг или нет
+ */
+
+ void OpenCell(int row, int col, boolean flag);
+
+ /**
+ * Метод для установки ссылки на объект IUserInterface
+ * для взраимодействия с ним (передача данных о проигрыше, победе)
+ *
+ * @param ui - Объект типа IUserInterface - интерфес пользователя
+ */
+ void setUserInterface(IUserInterface ui);
+
+ /**
+ * Метод проверяющий победил пользоваль или нет
+ * @return да или нет
+ */
+ boolean checkVictory();
+
+
+
+
+}
diff --git a/src/main/java/miner/IMineField.java b/src/main/java/miner/IMineField.java
new file mode 100644
index 0000000..ac62e99
--- /dev/null
+++ b/src/main/java/miner/IMineField.java
@@ -0,0 +1,32 @@
+/**
+ * Интерфейс IMineField описывает поведение минного поля, - различные методы,
+ * которые необходимы для создания игры Miner
+ */
+
+package miner;
+
+/**
+ * Created by Antony on 25.05.2016.
+ */
+public interface IMineField {
+
+
+ /**
+ * Makes cells array in MinesField
+ */
+ void createCells();
+
+ /**
+ * Blows all bombs on a field when a user is failed
+ */
+ void BlastAllBombs();
+
+ ICell[][] getCells();
+
+ /**
+ * redraw all cells on a field
+ */
+ void drawCells();
+
+
+}
diff --git a/src/main/java/miner/IUserInterface.java b/src/main/java/miner/IUserInterface.java
new file mode 100644
index 0000000..b9f86f4
--- /dev/null
+++ b/src/main/java/miner/IUserInterface.java
@@ -0,0 +1,30 @@
+/**
+ * Интерфейс описывает поведение самого приложения с игрой
+ * - пользовательского интерфеса
+ */
+
+package miner;
+
+/**
+ * Created by Antony on 25.05.2016.
+ */
+public interface IUserInterface {
+
+ /**
+ * Method to start the game
+ */
+ void StartGame();
+
+ /**
+ * Win the game, takes appropriate action and congratulates the user
+ */
+ void win();
+
+ /**
+ * Lose the game, takes appropriate action
+ */
+ void lose();
+
+ void showErrorMessage(String s);
+
+}
diff --git a/target/Miner-1.0-SNAPSHOT.jar b/target/Miner-1.0-SNAPSHOT.jar
new file mode 100644
index 0000000..8321ef6
Binary files /dev/null and b/target/Miner-1.0-SNAPSHOT.jar differ
diff --git a/target/classes/logic/GameLogic.class b/target/classes/logic/GameLogic.class
new file mode 100644
index 0000000..b04c9f6
Binary files /dev/null and b/target/classes/logic/GameLogic.class differ
diff --git a/target/classes/logic/Status.class b/target/classes/logic/Status.class
new file mode 100644
index 0000000..1ee1946
Binary files /dev/null and b/target/classes/logic/Status.class differ
diff --git a/target/classes/miner/AppMain$1.class b/target/classes/miner/AppMain$1.class
new file mode 100644
index 0000000..bbc04e1
Binary files /dev/null and b/target/classes/miner/AppMain$1.class differ
diff --git a/target/classes/miner/AppMain.class b/target/classes/miner/AppMain.class
new file mode 100644
index 0000000..c9282bb
Binary files /dev/null and b/target/classes/miner/AppMain.class differ
diff --git a/target/classes/miner/GUI/Cell.class b/target/classes/miner/GUI/Cell.class
new file mode 100644
index 0000000..99097a6
Binary files /dev/null and b/target/classes/miner/GUI/Cell.class differ
diff --git a/target/classes/miner/GUI/MainFrame.class b/target/classes/miner/GUI/MainFrame.class
new file mode 100644
index 0000000..a6d4f35
Binary files /dev/null and b/target/classes/miner/GUI/MainFrame.class differ
diff --git a/target/classes/miner/GUI/MineField.class b/target/classes/miner/GUI/MineField.class
new file mode 100644
index 0000000..23a82bf
Binary files /dev/null and b/target/classes/miner/GUI/MineField.class differ
diff --git a/target/classes/miner/GUI/UserAction.class b/target/classes/miner/GUI/UserAction.class
new file mode 100644
index 0000000..296be64
Binary files /dev/null and b/target/classes/miner/GUI/UserAction.class differ
diff --git a/target/classes/miner/ICell.class b/target/classes/miner/ICell.class
new file mode 100644
index 0000000..284f5a2
Binary files /dev/null and b/target/classes/miner/ICell.class differ
diff --git a/target/classes/miner/IGameLogic.class b/target/classes/miner/IGameLogic.class
new file mode 100644
index 0000000..5955d31
Binary files /dev/null and b/target/classes/miner/IGameLogic.class differ
diff --git a/target/classes/miner/IMineField.class b/target/classes/miner/IMineField.class
new file mode 100644
index 0000000..cbef01f
Binary files /dev/null and b/target/classes/miner/IMineField.class differ
diff --git a/target/classes/miner/IUserInterface.class b/target/classes/miner/IUserInterface.class
new file mode 100644
index 0000000..95e37ea
Binary files /dev/null and b/target/classes/miner/IUserInterface.class differ
diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties
new file mode 100644
index 0000000..be4c013
--- /dev/null
+++ b/target/maven-archiver/pom.properties
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Fri May 27 13:00:00 MSK 2016
+version=1.0-SNAPSHOT
+groupId=ru.Antony
+artifactId=Miner