Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.60 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()
  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 ServerUploader()    //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
  23.     {
  24.  
  25.     }
  26.  
  27.     static void UpdateArray(String a)
  28.     {
  29.         arr[0]=a.charAt(0);
  30.         arr[1]=a.charAt(1);
  31.         arr[2]=a.charAt(2);
  32.         arr[3]=a.charAt(3);
  33.         arr[4]=a.charAt(4);
  34.         arr[5]=a.charAt(5);
  35.         arr[6]=a.charAt(6);
  36.         arr[7]=a.charAt(7);
  37.         arr[8]=a.charAt(8);
  38.         arr[9]=a.charAt(9);
  39.     }
  40.  
  41.  
  42.  
  43.  
  44.     static int counter()
  45.     {
  46.         int tmp=0;
  47.         for (int i=1; i<10; i++)
  48.         {
  49.             if(arr[i]=='z') tmp++;
  50.         }
  51.         return tmp;
  52.     }
  53.     static void draw()
  54.     {
  55.  
  56.         if (arr[7]!='z')
  57.         {
  58.             System.out.print(arr[7]);
  59.         }
  60.         else
  61.         {
  62.             System.out.print('*');
  63.         }
  64.         if (arr[8]!='z')
  65.         {
  66.             System.out.print(arr[8]);
  67.         }
  68.         else
  69.         {
  70.             System.out.print('*');
  71.         }
  72.         if (arr[9]!='z')
  73.         {
  74.             System.out.println(arr[9]);
  75.         }
  76.         else
  77.         {
  78.             System.out.println('*');
  79.         }
  80.  
  81.  
  82.         if (arr[4]!='z')
  83.         {
  84.             System.out.print(arr[4]);
  85.         }
  86.         else
  87.         {
  88.             System.out.print('*');
  89.         }
  90.         if (arr[5]!='z')
  91.         {
  92.             System.out.print(arr[5]);
  93.         }
  94.         else
  95.         {
  96.             System.out.print('*');
  97.         }
  98.         if (arr[6]!='z')
  99.         {
  100.             System.out.println(arr[6]);
  101.         }
  102.         else
  103.         {
  104.             System.out.println('*');
  105.         }
  106.  
  107.  
  108.         if (arr[1]!='z')
  109.         {
  110.             System.out.print(arr[1]);
  111.         }
  112.         else
  113.         {
  114.             System.out.print('*');
  115.         }
  116.         if (arr[2]!='z')
  117.         {
  118.             System.out.print(arr[2]);
  119.         }
  120.         else
  121.         {
  122.             System.out.print('*');
  123.         }
  124.         if (arr[3]!='z')
  125.         {
  126.             System.out.print(arr[3]);
  127.         }
  128.         else
  129.         {
  130.             System.out.print('*');
  131.         }
  132.  
  133.     }
  134.  
  135.  
  136.  
  137.     public static void main(String[] args) {
  138.  
  139.  
  140.  
  141.         Scanner myObj = new Scanner(System.in);
  142.  
  143.         for (int i=0; i<10; i++)
  144.         {
  145.             arr[i]='z';
  146.         }
  147.  
  148.         while (counter()>0)
  149.         {
  150.  
  151.             char tmp =myObj.next().charAt(0);
  152.  
  153.  
  154.  
  155.             Boolean IsNumber=Character.isDigit(tmp);
  156.  
  157.             if (tmp=='r')
  158.             {
  159.                 System.out.println("Updating");
  160.                 ServerDownloader();
  161.             }
  162.  
  163.  
  164.  
  165.             if (IsNumber==true)
  166.             {
  167.                 ServerDownloader();
  168.                 int tmp2=Character.getNumericValue(tmp);
  169.                 if (arr[tmp2]=='z')
  170.                 {
  171.                     arr[tmp2]=ttt;
  172.                 }
  173.                 else
  174.                 {
  175.                     System.out.println("Impossible move");
  176.                 }
  177.             }
  178.             else
  179.             {
  180.  
  181.             }
  182.             draw();
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.         }
  190.  
  191.  
  192.  
  193.  
  194.  
  195.     }
  196. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement