Skip to content
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
9 changes: 9 additions & 0 deletions Answers/40230112005/Beater.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class Beater extends Player implements Success{
public boolean isSuccessful(){
int rand=(int)(Math.random()*101);
if(rand<41){
return true;
}
return false;
}
}
9 changes: 9 additions & 0 deletions Answers/40230112005/Chaser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class Chaser extends Player implements Success{
public boolean isSuccessful() {
int rand = (int) (Math.random() * 101);
if(rand<31){
return true;
}
return false;
}
}
9 changes: 9 additions & 0 deletions Answers/40230112005/Keeper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class Keeper extends Player implements Success{
public boolean isSuccessful() {
int rand = (int) (Math.random() * 101);
if(rand<71){
return true;
}
return false;
}
}
19 changes: 19 additions & 0 deletions Answers/40230112005/Match.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
public class Match {
Team team1=new Team();
Team team2=new Team();
public void start(){
for(int i=0 ; i<100 ; i++){
team1.Play();
team2.Play();
}
System.out.println("Team1 Score: " + team1.score());
System.out.println("Team2 Score: " + team2.score());
if(team2.score() > team1.score()){
System.out.println("Team2 Won!");
}else if(team2.score() < team1.score()) {
System.out.println("Team1 Won!");
}else{
System.out.println("Draw!");
}
}
}
6 changes: 6 additions & 0 deletions Answers/40230112005/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();
}
}
3 changes: 3 additions & 0 deletions Answers/40230112005/Player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class Player {

}
9 changes: 9 additions & 0 deletions Answers/40230112005/Seeker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class Seeker extends Player implements Success{
public boolean isSuccessful() {
int rand = (int) (Math.random() * 101);
if(rand<6){
return true;
}
return false;
}
}
3 changes: 3 additions & 0 deletions Answers/40230112005/Success.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface Success{
public boolean isSuccessful();
}
36 changes: 36 additions & 0 deletions Answers/40230112005/Team.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public class Team {
private int goal=0;
Keeper keeper1= new Keeper();
Chaser chaser1=new Chaser();
Chaser chaser2=new Chaser();
Chaser chaser3=new Chaser();
Beater beater1=new Beater();
Beater beater2=new Beater();
Seeker seeker1=new Seeker();

private void setGoal(){
goal++;
}

void Play() {
int chasercounter = 0;
if (chaser1.isSuccessful()) {
chasercounter++;
}
if (chaser2.isSuccessful()) {
chasercounter++;
}
if (chaser3.isSuccessful()) {
chasercounter++;
}
if (chasercounter > 1 && (beater1.isSuccessful() || beater2.isSuccessful()) && keeper1.isSuccessful()) {
goal++;
}
if (seeker1.isSuccessful()) {
goal += 150;
}
}
public int score(){
return goal;
}
}