Commit bd314920 authored by nargessalehi98's avatar nargessalehi98

one class

parents
Pipeline #3343 failed with stages
<?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>
import java.util.Random;
public class Main {
public static void main(String[] args) {
Random random = new Random();
int rand = random.nextInt(2);
String red = " 🔴 ";
String black = " ⚫ ";
Map map = new Map();
map.print();
if (rand == 0) {
while (true) {
map.putDisk(red);
map.print();
if (map.checkWinner(red)) {
System.out.println("\nRed is winner !");
break;
}
map.rotate();
map.print();
if (map.checkWinner(red) && map.checkWinner(black)) {
System.out.println("\nequal!");
break;
}else if(map.checkWinner(red)){
System.out.println("\nRed is winner !");
break;
}
else if(map.checkWinner(black)){
System.out.println("\nblack is winner !");
break;
}
map.putDisk(black);
map.print();
if (map.checkWinner(black)) {
System.out.println("\nblack is winner !");
break;
}
map.rotate();
map.print();
if (map.checkWinner(red) && map.checkWinner(black)) {
System.out.println("\nequal!");
break;
}else if(map.checkWinner(red)){
System.out.println("\nRed is winner !");
break;
}
else if(map.checkWinner(black)){
System.out.println("\nblack is winner !");
break;
}
}
} else {
while (true) {
map.putDisk(black);
map.print();
if (map.checkWinner(black)) {
System.out.println("\nblack is winner !");
break;
}
map.rotate();
map.print();
if (map.checkWinner(red) && map.checkWinner(black)) {
System.out.println("\nequal!");
break;
}else if(map.checkWinner(red)){
System.out.println("\nRed is winner !");
break;
}
else if(map.checkWinner(black)){
System.out.println("\nblack is winner !");
break;
}
map.putDisk(red);
map.print();
if (map.checkWinner(red)) {
System.out.println("\nRed is winner !");
break;
}
map.rotate();
map.print();
if (map.checkWinner(red) && map.checkWinner(black)) {
System.out.println("\nequal!");
break;
}else if(map.checkWinner(red)){
System.out.println("\nRed is winner !");
break;
}
else if(map.checkWinner(black)){
System.out.println("\nblack is winner !");
break;
}
}
}
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment