-
import java.util.Scanner;
-
public class assignment{
-
public static void main(String args[]){
-
String getError;
-
int result;
-
int f,s,q,em=0;
-
int c0=0,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0;
-
int drawBoard[][]=new int[6][7];
-
-
while (em==0){
-
System.out.println("5 | "+drawBoard[5][0]+" "+drawBoard[5][1]+" "+drawBoard[5][2]+" "+drawBoard[5][3]+" "+drawBoard[5][4]+" "+drawBoard[5][5]+" "+drawBoard[5][6]+
-
"\n4 | "+drawBoard[4][0]+" "+drawBoard[4][1]+" "+drawBoard[4][2]+" "+drawBoard[4][3]+" "+drawBoard[4][4]+" "+drawBoard[4][5]+" "+drawBoard[4][6]+
-
"\n3 | "+drawBoard[3][0]+" "+drawBoard[3][1]+" "+drawBoard[3][2]+" "+drawBoard[3][3]+" "+drawBoard[3][4]+" "+drawBoard[3][5]+" "+drawBoard[3][6]+
-
"\n2 | "+drawBoard[2][0]+" "+drawBoard[2][1]+" "+drawBoard[2][2]+" "+drawBoard[2][3]+" "+drawBoard[2][4]+" "+drawBoard[2][5]+" "+drawBoard[2][6]+
-
"\n1 | "+drawBoard[1][0]+" "+drawBoard[1][1]+" "+drawBoard[1][2]+" "+drawBoard[1][3]+" "+drawBoard[1][4]+" "+drawBoard[1][5]+" "+drawBoard[1][6]+
-
"\n0 | "+drawBoard[0][0]+" "+drawBoard[0][1]+" "+drawBoard[0][2]+" "+drawBoard[0][3]+" "+drawBoard[0][4]+" "+drawBoard[0][5]+" "+drawBoard[0][6]+
-
"\n -------------\n 0 1 2 3 4 5 6");
-
-
Scanner keyin=new Scanner(System.in);
-
System.out.print("Player 1 type a column (0-6) or 9 to quit current game:");
-
-
f=keyin.nextInt();
-
switch(f){
-
case 0:
-
drawBoard[c0][0]=1;
-
c0++;
-
break;
-
case 1:
-
drawBoard[c1][1]=1;
-
c1++;
-
break;
-
case 2:
-
drawBoard[c2][2]=1;
-
c2++;
-
break;
-
case 3:
-
drawBoard[c3][3]=1;
-
c3++;
-
break;
-
case 4:
-
drawBoard[c4][4]=1;
-
c4++;
-
break;
-
case 5:
-
drawBoard[c5][5]=1;
-
c5++;
-
break;
-
case 6:
-
drawBoard[c6][6]=1;
-
c6++;
-
break;
-
case 9:
-
System.out.print("Do you want to continue (Yes=1, No=0)?");
-
q=keyin.nextInt();
-
-
-
if (q==1)
-
continue;
-
else if (q==0)
-
System.exit(0);
-
}
-
System.out.println("5 | "+drawBoard[5][0]+" "+drawBoard[5][1]+" "+drawBoard[5][2]+" "+drawBoard[5][3]+" "+drawBoard[5][4]+" "+drawBoard[5][5]+" "+drawBoard[5][6]+
-
"\n4 | "+drawBoard[4][0]+" "+drawBoard[4][1]+" "+drawBoard[4][2]+" "+drawBoard[4][3]+" "+drawBoard[4][4]+" "+drawBoard[4][5]+" "+drawBoard[4][6]+
-
"\n3 | "+drawBoard[3][0]+" "+drawBoard[3][1]+" "+drawBoard[3][2]+" "+drawBoard[3][3]+" "+drawBoard[3][4]+" "+drawBoard[3][5]+" "+drawBoard[3][6]+
-
"\n2 | "+drawBoard[2][0]+" "+drawBoard[2][1]+" "+drawBoard[2][2]+" "+drawBoard[2][3]+" "+drawBoard[2][4]+" "+drawBoard[2][5]+" "+drawBoard[2][6]+
-
"\n1 | "+drawBoard[1][0]+" "+drawBoard[1][1]+" "+drawBoard[1][2]+" "+drawBoard[1][3]+" "+drawBoard[1][4]+" "+drawBoard[1][5]+" "+drawBoard[1][6]+
-
"\n0 | "+drawBoard[0][0]+" "+drawBoard[0][1]+" "+drawBoard[0][2]+" "+drawBoard[0][3]+" "+drawBoard[0][4]+" "+drawBoard[0][5]+" "+drawBoard[0][6]+
-
"\n -------------\n 0 1 2 3 4 5 6");
-
System.out.print("Player 2 type a column (0-6) or 9 to quit current game:");
-
s=keyin.nextInt();
-
switch(s){
-
case 0:
-
drawBoard[c0][0]=2;
-
c0++;
-
break;
-
case 1:
-
drawBoard[c1][1]=2;
-
c1++;
-
break;
-
case 2:
-
drawBoard[c2][2]=2;
-
c2++;
-
break;
-
case 3:
-
drawBoard[c3][3]=2;
-
c3++;
-
break;
-
case 4:
-
drawBoard[c4][4]=2;
-
c4++;
-
break;
-
case 5:
-
drawBoard[c5][5]=2;
-
c5++;
-
break;
-
case 6:
-
drawBoard[c6][6]=2;
-
c6++;
-
break;
-
case 9:
-
System.out.print("Do you want to continue (Yes=1, No=0)?");
-
q=keyin.nextInt();
-
if (q==1)
-
continue;
-
else if (q==0)
-
System.exit(0);
-
}
-
-
for(int i=1; i<=4; i++){
-
result = status(i);
-
}
-
}
-
-
public static int hasWon(){
-
int status = 0;
-
-
-
for (int row=0; row<6; row++)
-
{
-
for (int col=0; col<4; col++)
-
{
-
if (ConnectFourArray[col][row] != 0 &&
-
ConnectFourArray[col][row] == ConnectFourArray[col+1][row] &&
-
ConnectFourArray[col][row] == ConnectFourArray[col+2][row] &&
-
ConnectFourArray[col][row] == ConnectFourArray[col+3][row])
-
{status = 1;}
-
//status = true;//int winner;
-
-
if(status == 1)
-
{
-
-
-
System.out.println("Player 1 is the winner");
-
}
-
-
else if(status == 0)
-
{
-
-
-
System.out.println("Player 2 is the winner" );
-
}
-
-
}//end inner for loop
-
}// end outer for loop
-
} // end method Winner
-
-
return status;
-
Why i can't open the new main of this cheak win?
3 1824
Why i can't open the new main of this cheak win?
I don't understand your question, please rephrase it. btw, your code is overly
repetative and not very well organized.
kind regards,
Jos
ps. I added those [ code ] ... [ /code ] tags for you.
For this, plx tell me why the NeilClass does not exit?
For this, plx tell me why the NeilClass does not exit?
I don't know why that class doesn't exist. Maybe you haven't compiled it or
maybe it can't be found in the classpath list. Please don't dump all your code
here without those [ code ] tags. Read the instructions in the 'help' link before
you post here. (see the top of this page)
Also read the "Read This First" article near the top of this page for useful links.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Marc |
last post by:
Hello,
Newbie here..... Searching and working this for a week now.
We too are having the same problems.
Using MySql 4.0.14 and there are "no problems" at all.
|
by: John Glista |
last post by:
Hello. I'm having a bit of a problem with the HTTPSConnection class.
It is part of the httplib module. I discovered that it is not
neccessary to specifiy a key and a certificate when opening an...
|
by: Ryan |
last post by:
I have two similar stored procedures which I'm running. One runs and
one doesn't. I can run both with no problems in SQL Enterprise (7.0
standard) and have checked the permissions and am happy with...
|
by: CristianMori |
last post by:
Hi all
I find out that if I try to connect a socket in the .net compact framework
to a port that has no service binded to it, the socket tell me that it is
connected anyway!!!
I would like to...
|
by: Tim V. |
last post by:
Here's the layout: AIX v5.2, DB2 v8 fp8 running in 64bit
I've got a Multi-partitioned db running on lpar4 and I want to
connect it to 2 instances running on lpar13. We'll deal with just
1...
|
by: mayamorning123 |
last post by:
A comparison among six VSS remote tools including SourceOffSite ,
SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET
To view the full article, please visit...
|
by: Jerome Lyles |
last post by:
I'm trying to build a database. But none of the users I try to use works.
I as normal user doesn't work:
:~> createdb mydb
createdb: could not connect to database template1: FATAL: user...
|
by: ZR |
last post by:
I am writing two applications which needs to (among other things)
communicate through network, so one of them is a client and the other one is
a server. I have used asynchronous socket examples...
|
by: daft |
last post by:
Hi guys
Following on from an issue a couple of years back, now archived:
http://www.thescripts.com/forum/thread208561-tabledef.connect.html
I'm having the same problems.
I can update the...
|
by: koonda |
last post by:
Hi all,
I posted my message earliar and I got some positive feedbacks but that didn't help me to solve some programming problems. I have an Assignment due 20th of this month, next monday. The...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |