Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.51 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     static char arr[]= new char[10];
  8.  
  9.     static char ttt='X'; //Character that is either o or x
  10.  
  11.     static String ArrToSend()   //TO wysyłasz do serwera, on to zapisuje i wysyła każdemu z użytkowników, albo temu jedenmu co przydzielił go do pary
  12.     {
  13.         String str = String.valueOf(arr);
  14.         return str;
  15.     }
  16.  
  17.     static void ServerDownloader()  //Ta funkcja ma pobierać stringa z serwera. wywoła się ją za każdym razem jak będzie się chciało coś dodać do tablicy lub po naciśnięciu R
  18.     {
  19.  
  20.     }
  21.  
  22.     static void UpdateArray(String a)
  23.     {
  24.         arr[0]=a.charAt(0);
  25.         arr[1]=a.charAt(1);
  26.         arr[2]=a.charAt(2);
  27.         arr[3]=a.charAt(3);
  28.         arr[4]=a.charAt(4);
  29.         arr[5]=a.charAt(5);
  30.         arr[6]=a.charAt(6);
  31.         arr[7]=a.charAt(7);
  32.         arr[8]=a.charAt(8);
  33.         arr[9]=a.charAt(9);
  34.     }
  35.  
  36.  
  37.  
  38.  
  39.     static int counter()
  40.     {
  41.         int tmp=0;
  42.         for (int i=1; i<10; i++)
  43.         {
  44.             if(arr[i]=='z') tmp++;
  45.         }
  46.         return tmp;
  47.     }
  48.     static void draw()
  49.     {
  50.  
  51.         if (arr[7]!='z')
  52.         {
  53.             System.out.print(arr[7]);
  54.         }
  55.         else
  56.         {
  57.             System.out.print('*');
  58.         }
  59.         if (arr[8]!='z')
  60.         {
  61.             System.out.print(arr[8]);
  62.         }
  63.         else
  64.         {
  65.             System.out.print('*');
  66.         }
  67.         if (arr[9]!='z')
  68.         {
  69.             System.out.println(arr[9]);
  70.         }
  71.         else
  72.         {
  73.             System.out.println('*');
  74.         }
  75.  
  76.  
  77.         if (arr[4]!='z')
  78.         {
  79.             System.out.print(arr[4]);
  80.         }
  81.         else
  82.         {
  83.             System.out.print('*');
  84.         }
  85.         if (arr[5]!='z')
  86.         {
  87.             System.out.print(arr[5]);
  88.         }
  89.         else
  90.         {
  91.             System.out.print('*');
  92.         }
  93.         if (arr[6]!='z')
  94.         {
  95.             System.out.println(arr[6]);
  96.         }
  97.         else
  98.         {
  99.             System.out.println('*');
  100.         }
  101.  
  102.  
  103.         if (arr[1]!='z')
  104.         {
  105.             System.out.print(arr[1]);
  106.         }
  107.         else
  108.         {
  109.             System.out.print('*');
  110.         }
  111.         if (arr[2]!='z')
  112.         {
  113.             System.out.print(arr[2]);
  114.         }
  115.         else
  116.         {
  117.             System.out.print('*');
  118.         }
  119.         if (arr[3]!='z')
  120.         {
  121.             System.out.print(arr[3]);
  122.         }
  123.         else
  124.         {
  125.             System.out.print('*');
  126.         }
  127.  
  128.     }
  129.  
  130.  
  131.  
  132.     public static void main(String[] args) {
  133.  
  134.  
  135.  
  136.         Scanner myObj = new Scanner(System.in);
  137.  
  138.         for (int i=0; i<10; i++)
  139.         {
  140.             arr[i]='z';
  141.         }
  142.  
  143.         while (counter()>0)
  144.         {
  145.  
  146.             char tmp =myObj.next().charAt(0);
  147.  
  148.  
  149.  
  150.             Boolean IsNumber=Character.isDigit(tmp);
  151.  
  152.             if (tmp=='r')
  153.             {
  154.                 System.out.println("Updating");
  155.                 ServerDownloader();
  156.             }
  157.  
  158.  
  159.  
  160.             if (IsNumber==true)
  161.             {
  162.  
  163.                 int tmp2=Character.getNumericValue(tmp);
  164.                 if (arr[tmp2]=='z')
  165.                 {
  166.                     arr[tmp2]=ttt;
  167.                 }
  168.                 else
  169.                 {
  170.                     System.out.println("Impossible move");
  171.                 }
  172.             }
  173.             else
  174.             {
  175.  
  176.             }
  177.             draw();
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.         }
  185.  
  186.  
  187.  
  188.  
  189.  
  190.     }
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement