Skip to content
Snippets Groups Projects
Commit 31a9af37 authored by HEBBACHE Mohamed's avatar HEBBACHE Mohamed
Browse files

add builder

parent 24645ed3
Branches
No related tags found
No related merge requests found
Pipeline #25970 passed
Showing
with 24 additions and 9 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
package model.Builder;
public class Director {
IGameBuilder gameBuilder;
public Director(IGameBuilder gameBuilder){
this.gameBuilder=gameBuilder;
}
public void constructGame(int initialFireCount,int initialFirefighterCount,int initialCloudCount,int initialMotorizedFireFighterCount,
int initialMountainCount ,int initialRoadCount,int initialRockeryCount) {
this.gameBuilder.setFire(initialFireCount)
.setFireFighter(initialFirefighterCount)
.setRoad(initialRoadCount)
.setCloud(initialCloudCount)
.setMotorizedFireFighter(initialMotorizedFireFighterCount)
.setMountain(initialMountainCount)
.setRockery(initialRockeryCount)
.build();
}
}
package model; package model;
import model.Builder.Director;
import model.Builder.GameBuilder; import model.Builder.GameBuilder;
import model.Visitor.FireFinder; import model.Visitor.FireFinder;
...@@ -40,16 +41,11 @@ public class GameBoard implements Board{ ...@@ -40,16 +41,11 @@ public class GameBoard implements Board{
this.initialRockeryCount = initialRockeryCount; this.initialRockeryCount = initialRockeryCount;
} }
public void initializeElements(){ public void initializeElements(){
GameBuilder gameBuilder=new GameBuilder(); Director director=new Director(new GameBuilder());
gameBuilder.setFire(initialFireCount) director.constructGame(initialFireCount,initialFirefighterCount,initialCloudCount,initialMotorizedFireFighterCount,
.setFireFighter(initialFirefighterCount) initialMountainCount ,initialRoadCount,initialRockeryCount);
.setRoad(initialRoadCount)
.setCloud(initialCloudCount)
.setMotorizedFireFighter(initialMotorizedFireFighterCount)
.setMountain(initialMountainCount)
.setRockery(initialRockeryCount)
.build();
} }
public static Position randomPosition() { public static Position randomPosition() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment