diff options
Diffstat (limited to 'src/main/java')
24 files changed, 489 insertions, 37 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/controller/BlockController.java b/src/main/java/fr/umlv/java/wallj/controller/BlockController.java index 7ab6aec..bafa74a 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/BlockController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/BlockController.java | |||
@@ -1,8 +1,21 @@ | |||
1 | package fr.umlv.java.wallj.controller; | 1 | package fr.umlv.java.wallj.controller; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.context.Context; | 3 | import fr.umlv.java.wallj.context.Context; |
4 | import fr.umlv.java.wallj.event.Event; | ||
5 | import fr.umlv.java.wallj.model.Block; | ||
6 | |||
7 | import java.util.List; | ||
8 | import java.util.Objects; | ||
9 | |||
10 | public abstract class BlockController implements Controller { | ||
11 | |||
12 | private final Block block; | ||
13 | |||
14 | BlockController(Block block) { | ||
15 | this.block = Objects.requireNonNull(block); | ||
16 | } | ||
4 | 17 | ||
5 | public abstract class BlockController implements Controller{ | ||
6 | //TODO Check UML to implement BlockController | 18 | //TODO Check UML to implement BlockController |
7 | public abstract void update(Context context); | 19 | public abstract List<Event> update(Context context); |
20 | |||
8 | } | 21 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/controller/BlockControllerFactory.java b/src/main/java/fr/umlv/java/wallj/controller/BlockControllerFactory.java index c820315..89d45ca 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/BlockControllerFactory.java +++ b/src/main/java/fr/umlv/java/wallj/controller/BlockControllerFactory.java | |||
@@ -1,5 +1,49 @@ | |||
1 | package fr.umlv.java.wallj.controller; | 1 | package fr.umlv.java.wallj.controller; |
2 | 2 | ||
3 | public class BlockControllerFactory { | 3 | import fr.umlv.java.wallj.model.*; |
4 | //TODO | 4 | |
5 | import java.util.Arrays; | ||
6 | import java.util.Collections; | ||
7 | import java.util.List; | ||
8 | |||
9 | /** | ||
10 | * A block controller factory. | ||
11 | * "I am the man who arranges the blocks that descend upon me from up above..." | ||
12 | * | ||
13 | * @author Pacien TRAN-GIRARD | ||
14 | */ | ||
15 | public final class BlockControllerFactory { | ||
16 | |||
17 | /** | ||
18 | * @implNote no Lists.of in JDK8 | ||
19 | */ | ||
20 | private static List<BlockController> listOf(BlockController... controllers) { | ||
21 | return Collections.unmodifiableList(Arrays.asList(controllers)); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * Builds the controllers for the given block. | ||
26 | * | ||
27 | * @param b block | ||
28 | * @return list of controllers | ||
29 | */ | ||
30 | public static List<BlockController> build(Block b) { | ||
31 | if (b instanceof WallBlock) | ||
32 | return listOf(new WallPhysicsController((WallBlock) b), new WallDisplayController((WallBlock) b)); | ||
33 | if (b instanceof TrashBlock) | ||
34 | return listOf(new TrashPhysicsController((TrashBlock) b), new TrashDisplayController((TrashBlock) b)); | ||
35 | if (b instanceof GarbageBlock) | ||
36 | return listOf(new GarbagePhysicsController((GarbageBlock) b), new GarbageDisplayController((GarbageBlock) b)); | ||
37 | if (b instanceof RobotBlock) | ||
38 | return listOf(new RobotPhysicsController((RobotBlock) b), new RobotDisplayController((RobotBlock) b)); | ||
39 | if (b instanceof BombBlock) | ||
40 | return listOf(new BombPhysicsController((BombBlock) b), new BombDisplayController((BombBlock) b)); | ||
41 | |||
42 | return Collections.emptyList(); | ||
43 | } | ||
44 | |||
45 | private BlockControllerFactory() { | ||
46 | // static class | ||
47 | } | ||
48 | |||
5 | } | 49 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java b/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java index 43452d9..3347b73 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java | |||
@@ -1,10 +1,25 @@ | |||
1 | package fr.umlv.java.wallj.controller; | 1 | package fr.umlv.java.wallj.controller; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.context.Context; | 3 | import fr.umlv.java.wallj.context.Context; |
4 | import fr.umlv.java.wallj.event.Event; | ||
5 | import fr.umlv.java.wallj.model.BombBlock; | ||
6 | |||
7 | import java.util.List; | ||
8 | import java.util.Objects; | ||
4 | 9 | ||
5 | public class BombDisplayController extends DisplayController { | 10 | public class BombDisplayController extends DisplayController { |
11 | |||
12 | private final BombBlock bomb; | ||
13 | |||
14 | BombDisplayController(BombBlock bomb) { | ||
15 | super(bomb); | ||
16 | this.bomb = Objects.requireNonNull(bomb); | ||
17 | } | ||
18 | |||
6 | @Override | 19 | @Override |
7 | public void update(Context context) { | 20 | public List<Event> update(Context context) { |
8 | //TODO | 21 | //TODO |
22 | return null; | ||
9 | } | 23 | } |
24 | |||
10 | } | 25 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java b/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java index 948dcfb..02f00a3 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java | |||
@@ -1,10 +1,25 @@ | |||
1 | package fr.umlv.java.wallj.controller; | 1 | package fr.umlv.java.wallj.controller; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.context.Context; | 3 | import fr.umlv.java.wallj.context.Context; |
4 | import fr.umlv.java.wallj.event.Event; | ||
5 | import fr.umlv.java.wallj.model.BombBlock; | ||
6 | |||
7 | import java.util.List; | ||
8 | import java.util.Objects; | ||
4 | 9 | ||
5 | public class BombPhysicsController extends PhysicsController { | 10 | public class BombPhysicsController extends PhysicsController { |
11 | |||
12 | private final BombBlock bomb; | ||
13 | |||
14 | BombPhysicsController(BombBlock bomb) { | ||
15 | super(bomb); | ||
16 | this.bomb = Objects.requireNonNull(bomb); | ||
17 | } | ||
18 | |||
6 | @Override | 19 | @Override |
7 | public void update(Context context) { | 20 | public List<Event> update(Context context) { |
8 | //TODO | 21 | //TODO |
22 | return null; | ||
9 | } | 23 | } |
24 | |||
10 | } | 25 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/controller/Controller.java b/src/main/java/fr/umlv/java/wallj/controller/Controller.java index 91fe0c2..6a28d62 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/Controller.java +++ b/src/main/java/fr/umlv/java/wallj/controller/Controller.java | |||
@@ -1,7 +1,10 @@ | |||
1 | package fr.umlv.java.wallj.controller; | 1 | package fr.umlv.java.wallj.controller; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.context.Context; | 3 | import fr.umlv.java.wallj.context.Context; |
4 | import fr.umlv.java.wallj.event.Event; | ||
5 | |||
6 | import java.util.List; | ||
4 | 7 | ||
5 | public interface Controller { | 8 | public interface Controller { |
6 | void update(Context context); | 9 | List<Event> update(Context context); |
7 | } | 10 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/controller/DisplayController.java b/src/main/java/fr/umlv/java/wallj/controller/DisplayController.java index b368ddf..4b31a1c 100644 --- a/src/main/java/fr/umlv/java |