From 1cb0f39d2d0b6d85fa7df83749693efa22da5796 Mon Sep 17 00:00:00 2001 From: Amir Daouadi Date: Tue, 11 Apr 2023 23:41:40 +0200 Subject: [PATCH] Ajout du code pour le Random --- RandomDirection.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 RandomDirection.java diff --git a/RandomDirection.java b/RandomDirection.java new file mode 100644 index 0000000..455fe99 --- /dev/null +++ b/RandomDirection.java @@ -0,0 +1,15 @@ +import java.util.Random; + +public class RandomDirection { + public static final int UP = 0; + public static final int DOWN = 1; + public static final int LEFT = 2; + public static final int RIGHT = 3; + + public static int getRandomDirection() { + Random rand = new Random(); + int direction = rand.nextInt(4); + + return direction; + } +} \ No newline at end of file