Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

Fresher Job


 

Search Host

Monthly Fee($)
Disk Space (MB)
Register With us for Newsletter!
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

Tutorials

Java Server Pages

JAXB

Java Beans

JDBC

MySQL

Java Servlets

Struts

Bioinformatics

Java Code Examples

Interview Questions

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Web Promotion

Web Submission

Submit Sites

Manual Submission?

Web Promotion Guide

Hosting Companies

Web Hosting Guide

Web Hosting

Linux

Beginner Guide to Linux Server

Frameworks

Persistence Framework

Web Frameworks

Free EAI Tools

Web Servers

Aspect Oriented Programming

Free Proxy Servers

Softwares

Adware & Spyware Remover

Open Source Softwares

Stymied with Java code
Expert:John
In dire need of help with my Tic Tac Toe project due (past due actually) and would appreciate any help! Thanks in advance!

//December 01, 2008
//CIS 130 Lab9_TicTacToe1

import java.io.*;
import java.util.*;

public class Lab9_TicTacToe1
{
public static void main (String args [])
{
int moves, curr_player, cell, winner;

Scanner kb=new Scanner(System.in);

//string variable for names of players (player1 and player2)
moves=0;
cell=0;

int board[]=new int[9];

while((moves<9) && (winner == 0))
{
//input cell - if the cell is unoccupied (check value for 0)
{
moves++;

//set the br[cell] = curr_player;
//use switch statement to determine if that move makes the user a winner

switch(cell)
{
case 0:
if((br[0] == curr_player) && (br[1] == curr_player) && (br[2]==curr_player))
System.out.println("The winner is " + curr_player);
break;

case 1:
if((br[3] == curr_player) && (br[4] == curr_player) && (br[5]==curr_player))
System.out.println("The winner is " + curr_player);
break;

case 2:
if((br[6] == curr_player) && (br[7] == curr_player) && (br[8]==curr_player))
System.out.println("The winner is " + curr_player);
break;

case 3:
if((br[0] == curr_player) && (br[3] == curr_player) && (br[6]==curr_player))
System.out.println("The winner is " + curr_player);
break;

case 4:
if((br[1] == curr_player) && (br[4] == curr_player) && (br[7]==curr_player))
System.out.println("The winner is " + curr_player);
break;

case 5:
if((br[2] == curr_player) && (br[5] == curr_player) && (br[8]==curr_player))
System.out.println("The winner is " + curr_player);
break;

case 6:
if((br[0] == curr_player) && (br[4] == curr_player) && (br[8]==curr_player))
System.out.println("The winner is " + curr_player);
break;

case 7:
if((br[2] == curr_player) && (br[4] == curr_player) && (br[6]==curr_player))
System.out.println("The winner is " + curr_player);
break;

//similarly check other possible winning combination including 0 cell
}

//After getting out of switch display the board

if (winner == 0)
{
if(player == 1)
System.out.println(player = 2);

else
System.out.println(player = 1);
}
moves++;
}
}//end of for checking valid move

else
System.out.println("Invalid move.");
}//end while

if(winner != 0)
{
if(curr_player==1)
System.out.println(player2 + " is the winner.");
}
else
System.out.println("Game ended without a winner.");
}
}



I am just at a loss at my error and to finish this up for school- thanks!
Answers
More Questions
Post Answers
 
Ask Question Facing Programming Problem?
Useful Links
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.