aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/BlockController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/BlockControllerFactory.java48
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/Controller.java5
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/DisplayController.java7
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/GarbageDisplayController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/GarbagePhysicsController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/PhysicsController.java7
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/RobotDisplayController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/RobotPhysicsController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/TrashDisplayController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/TrashPhysicsController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/WallDisplayController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/WallPhysicsController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/model/Block.java72
-rw-r--r--src/main/java/fr/umlv/java/wallj/model/BlockFactory.java41
-rw-r--r--src/main/java/fr/umlv/java/wallj/model/BlockType.java56
-rw-r--r--src/main/java/fr/umlv/java/wallj/model/BombBlock.java30
-rw-r--r--src/main/java/fr/umlv/java/wallj/model/GarbageBlock.java16
-rw-r--r--src/main/java/fr/umlv/java/wallj/model/RobotBlock.java16
-rw-r--r--src/main/java/fr/umlv/java/wallj/model/StaticBlock.java5
-rw-r--r--src/main/java/fr/umlv/java/wallj/model/TrashBlock.java18
-rw-r--r--src/main/java/fr/umlv/java/wallj/model/WallBlock.java18
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 @@
1package fr.umlv.java.wallj.controller; 1package fr.umlv.java.wallj.controller;
2 2
3import fr.umlv.java.wallj.context.Context; 3import fr.umlv.java.wallj.context.Context;
4import fr.umlv.java.wallj.event.Event;
5import fr.umlv.java.wallj.model.Block;
6
7import java.util.List;
8import java.util.Objects;
9
10public 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
5public 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 @@
1package fr.umlv.java.wallj.controller; 1package fr.umlv.java.wallj.controller;
2 2
3public class BlockControllerFactory { 3import fr.umlv.java.wallj.model.*;
4 //TODO 4
5import java.util.Arrays;
6import java.util.Collections;
7import 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 */
15public 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 @@
1package fr.umlv.java.wallj.controller; 1package fr.umlv.java.wallj.controller;
2 2
3import fr.umlv.java.wallj.context.Context; 3import fr.umlv.java.wallj.context.Context;
4import fr.umlv.java.wallj.event.Event;
5import fr.umlv.java.wallj.model.BombBlock;
6
7import java.util.List;
8import java.util.Objects;
4 9
5public class BombDisplayController extends DisplayController { 10public 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 @@
1package fr.umlv.java.wallj.controller; 1package fr.umlv.java.wallj.controller;
2 2
3import fr.umlv.java.wallj.context.Context; 3import fr.umlv.java.wallj.context.Context;
4import fr.umlv.java.wallj.event.Event;
5import fr.umlv.java.wallj.model.BombBlock;
6
7import java.util.List;
8import java.util.Objects;
4 9
5public class BombPhysicsController extends PhysicsController { 10public 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 @@
1package fr.umlv.java.wallj.controller; 1package fr.umlv.java.wallj.controller;
2 2
3import fr.umlv.java.wallj.context.Context; 3import fr.umlv.java.wallj.context.Context;
4import fr.umlv.java.wallj.event.Event;
5
6import java.util.List;
4 7
5public interface Controller { 8public 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