Skip to content

Quidditch Done! #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Answers/40230212083/Beater.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Beater extends Player implements Success{
public boolean isSuccessful() {
int randNum = (int) (Math.random() * 101);
if(randNum<41) return true;
else return false;
}
}
7 changes: 7 additions & 0 deletions Answers/40230212083/Chaser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Chaser extends Player implements Success{
public boolean isSuccessful() {
int randNum = (int) (Math.random() * 101);
if(randNum<31) return true;
else return false;
}
}
7 changes: 7 additions & 0 deletions Answers/40230212083/Keeper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Keeper extends Player implements Success{
public boolean isSuccessful() {
int randNum = (int) (Math.random() * 101);
if(randNum<71) return true;
else return false;
}
}
19 changes: 19 additions & 0 deletions Answers/40230212083/Match.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
public class Match{
Team slytherin = new Team();
Team gryffindor = new Team();
public void start(){
for(int i=0;i<100;i++){
slytherin.play();
gryffindor.play();
}
System.out.println("Gryffindor Score: " + gryffindor.getScore());
System.out.println("Slytherin Score: " + slytherin.getScore());
if(slytherin.getScore() > gryffindor.getScore()) {
System.out.println("Slytherin Won !");
}else if(slytherin.getScore() < gryffindor.getScore()){
System.out.println("Gryffindor Won !");
}else{
System.out.println("Draw !");
}
}
}
6 changes: 6 additions & 0 deletions Answers/40230212083/MyApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class MyApp{
public static void main(String[] args){
Match game = new Match();
game.start();
}
}
4 changes: 4 additions & 0 deletions Answers/40230212083/Player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Player{
//What should we do here
//interface after function progarm ???
}
7 changes: 7 additions & 0 deletions Answers/40230212083/Seeker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Seeker extends Player implements Success{
public boolean isSuccessful() {
int randNum = (int) (Math.random() * 101);
if(randNum<6) return true;
else return false;
}
}
3 changes: 3 additions & 0 deletions Answers/40230212083/Success.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface Success{
public boolean isSuccessful();
}
26 changes: 26 additions & 0 deletions Answers/40230212083/Team.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
public class Team{
private int goalNum = 0;
Keeper ron = new Keeper();
Chaser ginny1 = new Chaser();
Chaser ginny2 = new Chaser();
Chaser ginny3 = new Chaser();
Beater george1 = new Beater();
Beater george2 = new Beater();
Seeker charlie = new Seeker();
private void setGoal(){
goalNum++;
}
void play(){
//at least 2 chaser
int chaserChance = 0;
if(ginny1.isSuccessful()) chaserChance++;
if(ginny2.isSuccessful()) chaserChance++;
if(ginny3.isSuccessful()) chaserChance++;
//
if((chaserChance>1) && (george1.isSuccessful() || george2.isSuccessful()) && ron.isSuccessful()) goalNum++;
if(charlie.isSuccessful()) goalNum += 150;
}
public int getScore(){
return goalNum;
}
}