1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
class Point{
public static Point p;
public static int i;
public Point(){
i=0;
}
public Point(int i){
this.i=i;
}
public int getPoint() {
return i;
}
public void setPoint(int i) {
i = i;
}
public String toString()
{
return getPoint()+"";
}
}
class Bateau{
public static int taille;
public static Point[] bat;
public Bateau(){
taille = 0; // Par défaut il a une taille 0
bat= new Point[taille];
}
// Constructeur de Bateau aléatoirement généré d'une certaine taille entrée en parametre
public Bateau(int c, int taille){
bat = new Point[taille];
for(int j = 0; j<bat.length; j++){
int res = c+j;
bat[j] = new Point(res);
}
for(int j = 0; j<bat.length; j++){
System.out.println("Création bateau :"+bat[j]);
}
}
public void afficheBateau(){
for(int j=0; j<bat.length; j++){
System.out.println("Affichage de la case "+j+" du bateau : "+bat[j]);
}
}
public Point getPoint(int i){
return bat[i];
}
public void setBateau(int i, Point t){
this.bat[i]=t;
}
public boolean estDansBat(Point p){
int i;
for(i=0;i<bat.length;i++){
if(p.getPoint()==bat[i].getPoint()){
return true;
}
}
return false;
}
} |
Partager