diff --git a/Answers/40230212039/project3/.idea/.gitignore b/Answers/40230212039/project3/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Answers/40230212039/project3/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Answers/40230212039/project3/.idea/description.html b/Answers/40230212039/project3/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/Answers/40230212039/project3/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/Answers/40230212039/project3/.idea/encodings.xml b/Answers/40230212039/project3/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/Answers/40230212039/project3/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Answers/40230212039/project3/.idea/misc.xml b/Answers/40230212039/project3/.idea/misc.xml new file mode 100644 index 0000000..dc47333 --- /dev/null +++ b/Answers/40230212039/project3/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230212039/project3/.idea/modules.xml b/Answers/40230212039/project3/.idea/modules.xml new file mode 100644 index 0000000..9bc4424 --- /dev/null +++ b/Answers/40230212039/project3/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Answers/40230212039/project3/.idea/project-template.xml b/Answers/40230212039/project3/.idea/project-template.xml new file mode 100644 index 0000000..1f08b88 --- /dev/null +++ b/Answers/40230212039/project3/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/Answers/40230212039/project3/out/production/project3/Beater.class b/Answers/40230212039/project3/out/production/project3/Beater.class new file mode 100644 index 0000000..54d76b9 Binary files /dev/null and b/Answers/40230212039/project3/out/production/project3/Beater.class differ diff --git a/Answers/40230212039/project3/out/production/project3/Chaser.class b/Answers/40230212039/project3/out/production/project3/Chaser.class new file mode 100644 index 0000000..4740c83 Binary files /dev/null and b/Answers/40230212039/project3/out/production/project3/Chaser.class differ diff --git a/Answers/40230212039/project3/out/production/project3/Keeper.class b/Answers/40230212039/project3/out/production/project3/Keeper.class new file mode 100644 index 0000000..a4b5eae Binary files /dev/null and b/Answers/40230212039/project3/out/production/project3/Keeper.class differ diff --git a/Answers/40230212039/project3/out/production/project3/Main.class b/Answers/40230212039/project3/out/production/project3/Main.class new file mode 100644 index 0000000..a9fe07d Binary files /dev/null and b/Answers/40230212039/project3/out/production/project3/Main.class differ diff --git a/Answers/40230212039/project3/out/production/project3/Match.class b/Answers/40230212039/project3/out/production/project3/Match.class new file mode 100644 index 0000000..247acb2 Binary files /dev/null and b/Answers/40230212039/project3/out/production/project3/Match.class differ diff --git a/Answers/40230212039/project3/out/production/project3/Myapp.class b/Answers/40230212039/project3/out/production/project3/Myapp.class new file mode 100644 index 0000000..4593896 Binary files /dev/null and b/Answers/40230212039/project3/out/production/project3/Myapp.class differ diff --git a/Answers/40230212039/project3/out/production/project3/Player.class b/Answers/40230212039/project3/out/production/project3/Player.class new file mode 100644 index 0000000..5847acd Binary files /dev/null and b/Answers/40230212039/project3/out/production/project3/Player.class differ diff --git a/Answers/40230212039/project3/out/production/project3/Seeker.class b/Answers/40230212039/project3/out/production/project3/Seeker.class new file mode 100644 index 0000000..52742ff Binary files /dev/null and b/Answers/40230212039/project3/out/production/project3/Seeker.class differ diff --git a/Answers/40230212039/project3/out/production/project3/Success.class b/Answers/40230212039/project3/out/production/project3/Success.class new file mode 100644 index 0000000..3d3879d Binary files /dev/null and b/Answers/40230212039/project3/out/production/project3/Success.class differ diff --git a/Answers/40230212039/project3/out/production/project3/Team.class b/Answers/40230212039/project3/out/production/project3/Team.class new file mode 100644 index 0000000..fc7884b Binary files /dev/null and b/Answers/40230212039/project3/out/production/project3/Team.class differ diff --git a/Answers/40230212039/project3/project3.iml b/Answers/40230212039/project3/project3.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Answers/40230212039/project3/project3.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230212039/project3/src/Beater.java b/Answers/40230212039/project3/src/Beater.java new file mode 100644 index 0000000..a38e974 --- /dev/null +++ b/Answers/40230212039/project3/src/Beater.java @@ -0,0 +1,16 @@ +import java.util.Random; + +public class Beater extends Player implements Success{ + + Beater(String name , int number){ + super(name , number); + } + + public boolean isSuccessful(){ + Random randomNum = new Random(); + int random = randomNum.nextInt(100) +1; + if (random <= 40){ + return true; + } else {return false;} + } +} diff --git a/Answers/40230212039/project3/src/Chaser.java b/Answers/40230212039/project3/src/Chaser.java new file mode 100644 index 0000000..0fba4b9 --- /dev/null +++ b/Answers/40230212039/project3/src/Chaser.java @@ -0,0 +1,17 @@ +import java.util.Random; + +public class Chaser extends Player implements Success{ + + Chaser(String name , int number){ + super(name , number); + } + + public boolean isSuccessful(){ + + Random randomNum = new Random(); + int random = randomNum.nextInt(100) +1; + if (random <=30){ + return true; + } else {return false;} + } +} diff --git a/Answers/40230212039/project3/src/Keeper.java b/Answers/40230212039/project3/src/Keeper.java new file mode 100644 index 0000000..1e52eb8 --- /dev/null +++ b/Answers/40230212039/project3/src/Keeper.java @@ -0,0 +1,17 @@ +import java.util.Random; + +public class Keeper extends Player implements Success { + + Keeper (String name , int number){ + super( name , number); + } + + public boolean isSuccessful(){ + + Random randomNum = new Random(); + int random = randomNum.nextInt(100) +1; + if (random <=70){ + return true; + } else {return false;} + } +} diff --git a/Answers/40230212039/project3/src/Main.java b/Answers/40230212039/project3/src/Main.java new file mode 100644 index 0000000..4a1dad2 --- /dev/null +++ b/Answers/40230212039/project3/src/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args){ + + + } +} diff --git a/Answers/40230212039/project3/src/Match.java b/Answers/40230212039/project3/src/Match.java new file mode 100644 index 0000000..ab07394 --- /dev/null +++ b/Answers/40230212039/project3/src/Match.java @@ -0,0 +1,41 @@ +public class Match { + + public void start () { + + Team teamNo1 = new Team(); + Team teamNo2 = new Team(); + + for (int i = 0; i < 100; i++) { + teamNo1.play(); + if (teamNo1.snitch) { + break; + } + teamNo2.play(); + if (teamNo2.snitch) { + break; + } + } + + if (teamNo1.snitch) { + System.out.println("Team 1 got the golden snitch."); + System.out.println("Team 1 : " + (teamNo1.goals + 150)); + System.out.println("Team 2 : " + teamNo2.goals); + System.out.println("Team 1 WINS!!"); + } else if (teamNo2.snitch) { + System.out.println("Team 2 got the golden snitch."); + System.out.println("Team 2 : " + (teamNo2.goals + 150)); + System.out.println("Team 1 : " + teamNo1.goals); + System.out.println("Team 2 WINS!!"); + } else if (teamNo1.goals > teamNo2.goals) { + System.out.println("Team 1 got " + teamNo1.goals + " scores and team 2 got " + teamNo2.goals + " scores."); + System.out.println("Team 1 WINS!!"); + } else if (teamNo2.goals > teamNo1.goals) { + System.out.println("Team 2 got " + teamNo2.goals + " scores and team 1 got " + teamNo1.goals + " scores."); + System.out.println("Team 2 WINS!!"); + } else if (teamNo2.goals == teamNo1.goals) { + System.out.println("The final score for team 1 is " + teamNo1.goals + " and for team 2 is " + teamNo2.goals); + System.out.println("So the game ends in a draw!"); + } + } + } + diff --git a/Answers/40230212039/project3/src/Myapp.java b/Answers/40230212039/project3/src/Myapp.java new file mode 100644 index 0000000..3b0ed28 --- /dev/null +++ b/Answers/40230212039/project3/src/Myapp.java @@ -0,0 +1,7 @@ +public class Myapp { + public static void main(String[] args) { + Match match = new Match(); + match.start(); + + } +} diff --git a/Answers/40230212039/project3/src/Player.java b/Answers/40230212039/project3/src/Player.java new file mode 100644 index 0000000..a77617b --- /dev/null +++ b/Answers/40230212039/project3/src/Player.java @@ -0,0 +1,14 @@ +public class Player implements Success{ + + public String name; + public int number; + + Player (String name , int number){ + this.name = name; + this.number = number; + } + + public boolean isSuccessful(){ + return false; + } +} diff --git a/Answers/40230212039/project3/src/Seeker.java b/Answers/40230212039/project3/src/Seeker.java new file mode 100644 index 0000000..a9190ad --- /dev/null +++ b/Answers/40230212039/project3/src/Seeker.java @@ -0,0 +1,17 @@ +import java.util.Random; + +public class Seeker extends Player implements Success{ + + Seeker(String name , int number){ + super(name , number); + } + + public boolean isSuccessful(){ + + Random randomNum = new Random(); + int random = randomNum.nextInt(100) +1; + if (random <=5){ + return true; + } else {return false;} + } +} diff --git a/Answers/40230212039/project3/src/Success.java b/Answers/40230212039/project3/src/Success.java new file mode 100644 index 0000000..c748298 --- /dev/null +++ b/Answers/40230212039/project3/src/Success.java @@ -0,0 +1,3 @@ +public interface Success { + public boolean isSuccessful(); +} diff --git a/Answers/40230212039/project3/src/Team.java b/Answers/40230212039/project3/src/Team.java new file mode 100644 index 0000000..a970bc0 --- /dev/null +++ b/Answers/40230212039/project3/src/Team.java @@ -0,0 +1,32 @@ +public class Team { + + Keeper keeper1= new Keeper("keeper" , 1); + Beater beater1 = new Beater("beater" , 2); + Beater beater2 = new Beater("beater" , 3); + Chaser chaser1 = new Chaser("chaser" , 4); + Chaser chaser2 = new Chaser("chaser" , 5); + Chaser chaser3 = new Chaser("chaser" , 6); +Seeker seeker1 = new Seeker("seeker" , 7); + +int goals = 0; +private void setGoal(){ +goals++; +} + + boolean snitch = false; + public void play() { + if (seeker1.isSuccessful()) { + snitch = true; + } + + if (keeper1.isSuccessful()) { + if (beater1.isSuccessful() || beater2.isSuccessful()) { + if ((chaser1.isSuccessful() && chaser2.isSuccessful()) || + (chaser2.isSuccessful() && chaser3.isSuccessful()) || + (chaser1.isSuccessful() && chaser3.isSuccessful())) { + setGoal(); + } + } + } + } + } diff --git a/Answers/40230212039/project3/src/com/company/Main.java b/Answers/40230212039/project3/src/com/company/Main.java new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Answers/40230212039/project3/src/com/company/Main.java @@ -0,0 +1 @@ +