Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package piskvorky;
- import java.util.*;
- public class Piskvorky {
- static int vPole = 3;
- static int[][] hra = new int[vPole][vPole];
- static boolean konec = true;
- static int hrac = 1;
- public static void main(String[] args) {
- int x;
- int y;
- Scanner sc = new Scanner(System.in);
- while (konec) {
- System.out.println("Hraje hrac " + hrac);
- if (hrac == 1) {
- System.out.println("Zadejte osu x");
- x = sc.nextInt();
- System.out.println("Zadejte osu y");
- y = sc.nextInt();
- if (hra[x][y] != 1 || hra[x][y] != 2) {
- hra[x][y] = hrac;
- hrac = 2;
- }
- } else {
- System.out.println("Zadejte osu x");
- x = sc.nextInt();
- System.out.println("Zadejte osu y");
- y = sc.nextInt();
- if (hra[x][y] != 1 || hra[x][y] != 2) {
- hra[x][y] = hrac;
- hrac = 2;
- }
- }
- zobrazPole();
- }
- }
- public static void zobrazPole() {
- for (int g = 0; g < vPole * 2 + 1; g++) {
- System.out.print("-");
- }
- System.out.println("");
- for (int i = 0; i < vPole; i++) {
- for (int j = 0; j < vPole; j++) {
- System.out.print("|");
- if (hra[i][j] == 1) {
- System.out.print("O");
- } else if (hra[i][j] == 2) {
- System.out.print("X");
- } else {
- System.out.print(" ");
- }
- }
- System.out.println("|");
- for (int g = 0; g < vPole * 2 + 1; g++) {
- System.out.print("-");
- }
- System.out.println("");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement