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
29 changes: 29 additions & 0 deletions Answers/40230112136/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
3 changes: 3 additions & 0 deletions Answers/40230112136/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Answers/40230112136/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Answers/40230112136/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Answers/40230112136/queedich.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
7 changes: 7 additions & 0 deletions Answers/40230112136/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
public static void main(String[] args) {

}
}
6 changes: 6 additions & 0 deletions Answers/40230112136/src/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 Match = new match();
Match.start();
}
}
17 changes: 17 additions & 0 deletions Answers/40230112136/src/beater.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import java.util.Random;

public class beater extends player implements success {
beater(int number, String name) {
super(number, name);
}

public boolean issuccssful(){

Random rand = new Random();
int upperbound = 100;
int darsad = rand.nextInt(upperbound) + 1;
if(darsad <= 40 ){return true;}
else {return false;}

}
}
14 changes: 14 additions & 0 deletions Answers/40230112136/src/chaser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.util.Random;

public class chaser extends player implements success{
chaser(int number , String name)
{super(number, name);}
public boolean issuccssful(){

Random rand = new Random();
int upperbound = 100;
int darsad = rand.nextInt(upperbound) + 1;
if(darsad <= 30 ){return true;}
else{ return false;}
}
}
14 changes: 14 additions & 0 deletions Answers/40230112136/src/keeper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.util.Random;

public class keeper extends player implements success{
keeper(int number , String name)
{super(number, name);}
public boolean issuccssful(){

Random rand = new Random();
int upperbound = 100;
int darsad = rand.nextInt(upperbound) + 1;
if(darsad <= 70 ){return true;}
else{return false;}
}
}
43 changes: 43 additions & 0 deletions Answers/40230112136/src/match.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
public class match {

public void start(){
team t1= new team();
team t2= new team();
for(int i=0 ; i<100 ; i++){
t1.play();
if(t1.snitch){break;}
t2.play();
if(t2.snitch){break;}
}

if(t1.snitch){
System.out.println("Team 1 got the snitch and wins with "+( 150 + t1.goal )+ "scores");
System.out.println("Team 2 scores " + t2.goal);
}
else if(t2.snitch){
System.out.println("Team 2 got the snitch and wins with "+( 150 + t2.goal )+ "scores");
System.out.println("Team 1 scores " + t1.goal);
}
else if(t1.goal > t2.goal)
{
System.out.println("Team 1 scores " + t1.goal);
System.out.println("Team 2 scores " + t2.goal);
System.out.println("Team 1 wins");
}
else if(t1.goal < t2.goal)
{
System.out.println("Team 1 scores " + t1.goal);
System.out.println("Team 2 scores " + t2.goal);
System.out.println("Team 2 wins");
}
else if(t1.goal == t2.goal)
{
System.out.println("Team 1 scores " + t1.goal);
System.out.println("Team 2 scores " + t2.goal);
System.out.println("The game ends in a draw.");
}



}
}
12 changes: 12 additions & 0 deletions Answers/40230112136/src/player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class player implements success {

public int _number;
public String _name;
player(int number , String name) {
_name = name;
_number = number;
}
public boolean issuccssful(){
return false;
}
}
16 changes: 16 additions & 0 deletions Answers/40230112136/src/seeker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import java.util.Random;

public class seeker extends player implements success{
seeker(int number , String name)
{super(number, name);}
public boolean issuccssful(){

Random rand = new Random();
int upperbound = 100;
int darsad = rand.nextInt(upperbound) + 1;
if(darsad <= 5 ){return true;}
else {return false;}

}

}
5 changes: 5 additions & 0 deletions Answers/40230112136/src/success.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public interface success {
public boolean issuccssful();


}
27 changes: 27 additions & 0 deletions Answers/40230112136/src/team.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class team {
keeper k= new keeper( 1 , "k");
seeker s= new seeker(2, "s");
chaser ch1 = new chaser(3, "ch1");
chaser ch2 = new chaser(4,"ch2");
chaser ch3 = new chaser(5, "ch3");
beater b1= new beater(6 ,"b1");
beater b2= new beater(7 , "b2");

int goal=0;

private void setgoal(){
goal++;
}
boolean snitch = false;

public void play() {
if(s.issuccssful()) snitch = true;
boolean first = k.issuccssful();
boolean second = (b1.issuccssful() || b2.issuccssful());
boolean third = ((ch1.issuccssful() && ch2.issuccssful()) || (ch2.issuccssful() && ch3.issuccssful()) || (ch1.issuccssful() && ch3.issuccssful()));

if (first && second && third) {
setgoal();
}
}
}