From 1f35815c75a1af5d3e1cd793ba08e4e3e09b5663 Mon Sep 17 00:00:00 2001 From: JunkJumper Date: Fri, 10 Apr 2020 18:06:38 +0200 Subject: [PATCH] =?UTF-8?q?fin=20journ=C3=A9e=20vendredi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 1 - src/ihm/.gitkeep | 0 src/jeu/components/.gitkeep | 0 src/jeu/utils/.gitkeep | 0 src/tmpmeth/DamageCalculator.java | 13 +++++++++++++ src/tmpmeth/Dice.java | 24 ++++++++++++++++++++++++ src/tmpmeth/start.java | 13 +++++++++++++ 7 files changed, 50 insertions(+), 1 deletion(-) delete mode 100644 _config.yml create mode 100644 src/ihm/.gitkeep create mode 100644 src/jeu/components/.gitkeep create mode 100644 src/jeu/utils/.gitkeep create mode 100644 src/tmpmeth/DamageCalculator.java create mode 100644 src/tmpmeth/Dice.java create mode 100644 src/tmpmeth/start.java diff --git a/_config.yml b/_config.yml deleted file mode 100644 index c419263..0000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-cayman \ No newline at end of file diff --git a/src/ihm/.gitkeep b/src/ihm/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/jeu/components/.gitkeep b/src/jeu/components/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/jeu/utils/.gitkeep b/src/jeu/utils/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/tmpmeth/DamageCalculator.java b/src/tmpmeth/DamageCalculator.java new file mode 100644 index 0000000..65e71d9 --- /dev/null +++ b/src/tmpmeth/DamageCalculator.java @@ -0,0 +1,13 @@ +package tmpmeth; + +public class DamageCalculator { + + public static int calculDamage(Dice d6, Dice d4) { + int r = d6.roll() - d4.roll(); + if(r < 0) { + r = 0; + } + return r; + } +} + diff --git a/src/tmpmeth/Dice.java b/src/tmpmeth/Dice.java new file mode 100644 index 0000000..54d6040 --- /dev/null +++ b/src/tmpmeth/Dice.java @@ -0,0 +1,24 @@ +package tmpmeth; +import java.lang.Math; + +public class Dice { + + private int max; + + public Dice() { + this(0); + } + + public Dice(int m) { + this.max = m; + } + + public int roll() { + return (int)((max)*Math.random())+1; + } + + public int getMax() { + return this.max; + } + +} diff --git a/src/tmpmeth/start.java b/src/tmpmeth/start.java new file mode 100644 index 0000000..bb2c7d8 --- /dev/null +++ b/src/tmpmeth/start.java @@ -0,0 +1,13 @@ +package tmpmeth; + +public class start { + + public static void main(String[] args) { + // TODO Auto-generated method stub + Dice d4 = new Dice(4); + Dice d6 = new Dice(6); + + System.out.println(DamageCalculator.calculDamage(d6, d4)); + + } +}