package Program3;
import java.util.Scanner;
public class program3 {
public static void main (String [] args)
{
Scanner Scan = new Scanner (System.in);
String ch1 = "1";
String ch2 = "2";
String ch3 = "3";
String ch4 = "4";
String ch5 = "5";
String ch6 = "6";
String ch7 = "7";
String ch8 = "8";
String ch9 = "9";
printGrid(ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9);
}
which(true)
{
While(true);
{System.out.print("Player 1 please make your move > ");
String player1 = Scan.next();
Scanner p1 = new Scanner (player1);
if (p1.hasnextInt())
{int playmore =p1.nextInt();}
switch(playmore)
{
case 1:
ch1=p1;
printGrid(ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9);
break;
case 2:
ch2=p1;
printGrid(ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9);
break;
case 3:
ch3=p1;
printGrid(ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9);
break;
case 4:
ch4=p1;
printGrid(ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9);
break;
case 5:
ch5=p1;
printGrid(ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9);
break;
case 6:
ch6=p1;
printGrid(ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9);
break;
case 7:
ch7=p1;
printGrid(ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9);
break;
case 8:
ch8=p1;
printGrid(ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9);
break;
case 9:
ch9=p1;
printGrid(ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9);
break;
}
else
{System.out.print("you have input invalid data please enter an integer");}
continue;
break;}
}
public static void printGrid( String a, String b, String c, String d, String e, String f, String g, String h , String i )
{
System.out.println(a+" / "+b+" / "+c);
System.out.println( "-----");
System.out.println( d+" / "+e+" / "+f);
System.out.println( "-----");
System.out.println( g+" / "+h+" / "+i);
}
}
Mod edit - Please

New Topic/Question
Reply




MultiQuote





|