-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMazeFloors.java
64 lines (58 loc) · 2 KB
/
MazeFloors.java
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
import java.io.*;
import java.text.Normalizer;
import java.util.*;
import java.awt.*;
public class MazeFloors implements Serializable,Cloneable{
private LinkedList<Maze> mazes;
private int nbFloors;
public MazeFloors(int L, int l, int nb)throws FormatNotSupported{
this(L,l,nb,0,0,0,0,0,0);
}
public MazeFloors(Maze m){
mazes=new LinkedList<Maze>();
mazes.add(m);
nbFloors=0;
}
public LinkedList<Maze>getFloor(){
return mazes;
}
public MazeFloors(LinkedList<Maze> m){
mazes=m;
nbFloors=m.size();
}
public MazeFloors(int L, int l, int nb, int nbObstacles, int nbMonstres,int nbTeleport,int nbDoors,int nbBonus, int typeBonus) throws FormatNotSupported{
if(nb==0) throw new FormatNotSupported("You must put a number of floors, min 1");
mazes=new LinkedList<Maze>();
nbFloors=nb;
while(nb!=0){
mazes.add(new Maze(L,l,nbObstacles,nbMonstres,nbTeleport,nbDoors,nbBonus,typeBonus)); //problèmes dans getcase pour teleporteur et porte
nb--;
}
if(nbFloors!=1) {
for (int i = 0; i < mazes.size(); i++) {
Maze m = mazes.get(i);
if (i == 0) m.changeEnding();
else if (i == mazes.size() - 1) m.changeBeginning();
else {
m.changeBeginning();
m.changeEnding();
}
}
}
}
public MazeFloors clone() throws CloneNotSupportedException{
LinkedList<Maze> m=new LinkedList<>();
for(Maze ma:this.mazes) m.add(ma.clone());
return new MazeFloors(m);
}
public void print(){ //affiche le labyrinthe dans le terminal
for(int i=0; i<mazes.size(); i++){
mazes.get(i).print();
System.out.println("Next Floor!!");
}
}
public static void main(String []args) throws FormatNotSupported{
MazeFloors mf=new MazeFloors(20,10,3,0,0,0,0,3,0);
mf.print();
}
}