blob: 6911c88635fb832187e06cca01a02bb25e38592d (
plain)
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
|
package fr.umlv.java.wallj.block;
import fr.umlv.java.wallj.board.TileVec2;
import org.jbox2d.common.Vec2;
/**
* A block factory.
*
* @author Pacien TRAN-GIRARD
*/
public final class BlockFactory {
private static Block forType(BlockType t, Vec2 pos) {
switch (t) {
case WALL:
return new WallBlock(pos);
case TRASH:
return new TrashBlock(pos);
case GARBAGE:
return new GarbageBlock(pos);
case ROBOT:
return new RobotBlock(pos);
case BOMB:
return new BombBlock(pos);
case FREE:
default:
return null;
}
}
/**
* @param type the type of the block to build
* @param pos the initial position of the block
* @return the built block
*/
public static Block build(BlockType type, TileVec2 pos) {
return forType(type, pos.toVec2());
}
private BlockFactory() {
// static class
}
}
|