Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
28a1702bfd
@ -13,7 +13,7 @@ public abstract class Player {
|
|||||||
protected ArrayList<Ship> ships = new ArrayList<>();
|
protected ArrayList<Ship> ships = new ArrayList<>();
|
||||||
protected ArrayList<Triplet<Integer,Integer,Boolean>> moves = new ArrayList<>();
|
protected ArrayList<Triplet<Integer,Integer,Boolean>> moves = new ArrayList<>();
|
||||||
protected int id;
|
protected int id;
|
||||||
protected final int[] bato = { 5, 4, 3, 3, 2};
|
protected final static int[] bato = { 5, 4, 3, 3, 2};
|
||||||
|
|
||||||
public boolean setShips(Ship ship) {
|
public boolean setShips(Ship ship) {
|
||||||
if(ship.getDirection() == Direction.DEFAULT)
|
if(ship.getDirection() == Direction.DEFAULT)
|
||||||
|
@ -60,8 +60,6 @@ public class Terminal extends View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayBoard() {
|
public void displayBoard() {
|
||||||
System.out.println(toString());
|
System.out.println(toString());
|
||||||
|
@ -6,6 +6,7 @@ import battleship.model.player.Player;
|
|||||||
import battleship.utils.Pair;
|
import battleship.utils.Pair;
|
||||||
import battleship.utils.Triplet;
|
import battleship.utils.Triplet;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ public abstract class View {
|
|||||||
|
|
||||||
public abstract void setShips(Player player);
|
public abstract void setShips(Player player);
|
||||||
|
|
||||||
public abstract void displayBoard(/*Graphics g*/);
|
public abstract void displayBoard();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -3,17 +3,24 @@ package battleship.view;
|
|||||||
import battleship.model.Game;
|
import battleship.model.Game;
|
||||||
import battleship.model.player.Player;
|
import battleship.model.player.Player;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.geom.Line2D;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class Window extends View {
|
public class Window extends View {
|
||||||
|
|
||||||
private JFrame frame;
|
private JFrame frame;
|
||||||
|
private final int hauteur = 600;
|
||||||
|
private final int largeur = 1200;
|
||||||
|
|
||||||
public Window(Game game) {
|
public Window(Game game) {
|
||||||
super(game);
|
super(game);
|
||||||
this.frame = new JFrame("Battleship");
|
this.frame = new JFrame("Battleship");
|
||||||
frame.setSize(600,400);
|
frame.setSize(largeur+largeur/38,hauteur+hauteur/13);
|
||||||
|
frame.setContentPane(new Draw());
|
||||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
@ -23,12 +30,35 @@ public class Window extends View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
class Draw extends JPanel {
|
||||||
public void displayBoard() {
|
public void paintComponent(Graphics g) {
|
||||||
|
/*JTextArea area = new JTextArea();
|
||||||
}
|
area.setBounds(20,10,400,20);
|
||||||
|
//area.append("A B C D E F G H I J");
|
||||||
|
frame.add(area);*/
|
||||||
|
for (int abscisse=largeur/24; abscisse<largeur+1; abscisse+=largeur/24) {
|
||||||
|
g.drawLine(abscisse, hauteur/6, abscisse, hauteur);
|
||||||
|
if ( largeur*0.44167 < abscisse && abscisse < largeur/2) {
|
||||||
|
abscisse += largeur/24 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int ordonnee=hauteur/6; ordonnee<hauteur+1; ordonnee+=hauteur/12) {
|
||||||
|
g.drawLine(largeur/24, ordonnee, (int) (largeur/2.18), ordonnee);
|
||||||
|
g.drawLine((int) (largeur/1.845), ordonnee, largeur, ordonnee);
|
||||||
|
}
|
||||||
|
TextArea a = new TextArea("Aouiuxdytftgykhulijhguhghf");
|
||||||
|
setLayout(new GridLayout(largeur, hauteur));
|
||||||
|
a.replaceRange("dqsdqsfdqsd", 0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void designBoard(Graphics g) {
|
public void designBoard(Graphics g) {
|
||||||
//super.paintComponent(g);
|
frame.paintComponents(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayBoard() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user