Java with OOP assignment (Eclipse) 1 Answer(s) 3 years and 3 months ago
Posted in : Java Beginners
"THREE Ts GAME"
*Description*
A "tic-tac-toe" game is a two player's board game where the game board is made of 3 X 3 grids. The two players, one being assigned with 'O' and the other with 'X', where each if the two players take turns marking the spaces in a 3 X 3 grid, for example X for the first player. The player who succeeds in placing three respective marks in horizontal, vertical or diagonal row wins the game.
A "toe-tac-tic" game is the opposite of a "tic-tac-toe". In "toe-tac-tic" game, you try to get your opponent to get three in a row either horizontally, vertically or diagonally. The winner is the player who does not get three in a row.
In this assignment, you are required to write both the "tic-tac-toe" and "toe-tac-tic" games using Java. When your game application started, the players will be able to choose either to play "tic-tac-toe" or "toe-tac-tic" game.
*Requirements*
1. The game must be GUI based. 2. Create all the necessary classes. At least one of the classes must be an abstract class with at least one abstract, method and all classes will have one or more constructors. 3. All classes must be part of the threeTsGame package. 4. All errors must be handled. 5. Create the html javadoc for the threeTsGame package.
View Answers
March 23, 2010 at 10:11 AM
Here is what I have done, but in Applet form. Anyone who knows how to convert my algorithm to GUI based program?
public class TicTacToe extends JApplet { // Indicate which player has a turn; initially it is the X player private char whoseTurn = 'X';
// Create and initialize cells private Cell[][] cells = new Cell[3][3];
// Create and initialize a status label private JLabel jlblStatus = new JLabel ("X's turn to play");
/** Initialize UI */ public TicTacToe() { JPanel p = new JPanel(new GridLayout(3, 3, 0, 0)); for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) p.add(cells[i][j] = new Cell());
// Set line borders on the cell panel and the status label p.setBorder(new LineBorder(Color.red, 1)); jlblStatus.setBorder(new LineBorder(Color.yellow, 1));
// Place the panel and the label to the applet add(p, BorderLayout.CENTER); add(jlblStatus, BorderLayout.SOUTH); }
/** Determine if the cells are all occupied */ public boolean isFull() { for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) if (cells[i][j].getToken() == ' ') return false;
return true; }
/** Determine if the player with the specified token wins */ public boolean isWon(char token) { for (int i = 0; i < 3; i++) if ((cells[i][0].getToken() == token) &&(cells[i][1].getToken() == token) &&(cells[i][2].getToken() == token)) { return true; }
private class MyMouseListener extends MouseAdapter { /** Handle mouse click on a cell */ public void mouseClicked(MouseEvent e) { // If cell is empty and game is not over if (token == ' ' && whoseTurn != ' ') { setToken(whoseTurn);
//Check game status if (isWon(whoseTurn)) { jlblStatus.setText(whoseTurn + "Win! The game is over"); whoseTurn = ' '; } else if (isFull()) { jlblStatus.setText("Draw! The game is over"); whoseTurn = ' '; } else { // Change the turn whoseTurn = (whoseTurn == 'X') ? '0': 'X'; // Display whose turn jlblStatus.setText(whoseTurn + "'s turn"); } } } } } }
Related Pages:
Java with OOP assignment (Eclipse) Java with OOPassignment (Eclipse) How do i control the length of characters in an input?
E.g.:
Enter your name > Hi
* Name too short
Java with OOP assignment (Eclipse) - Java Beginners Java with OOPassignment (Eclipse) "THREE Ts GAME"
*Description....
In this assignment, you are required to write both the "tic-tac-toe" and "toe-tac-tic" games using Java. When your game application started, the players will be able
Assignment
Assignment any one can help with a javaassignment
assignment
assignment Write a Java program that reads a file and prints
the amount of palindromes contained within the file
assignment
assignment Hi guys i wanna Know how to code for the following output in java.
*
**
***
****
*****
please guys if there is any1 who can help please do. System.out.printf
assignment
:
Write a Java program that will declare an array of THREE (3) Circle objects based
oop
oop can you tell me about why java is not 100% object oriented language
OOP OOP
OO Analysis & Design
Classes represent domain elements.
May... classes
UML is most common visual modelling technique
is-a vs has-a
Java... a home to utility functions.
Create immutable objects.
Java 5 autoboxing
JAVA assignment JAVA assignment Is there any1 on this site who can write a java... want small java application? Please specify the type of java program you want.
Have a look at the following link. This link consists of several java program
java oop java oop Design and implement a class called DayType that implements the day of the week in a program. The class DayType should store the day, such as Sun for Sunday, Mon for Monday and so on and so forth. The program should
Masters of Java Assignment Plugin
Masters of JavaAssignment Plugin
 ... of the EclipseJava IDE.
The plugin has the following features :
New Masters of JavaAssignment Wizard which sets up project structure
java assignment - Java Beginners java assignment I got assignment in "design a vehicle class hierarchy in java,write a test program to demonstrate polymorphism".please send me the necessary codings and algorithm. Hi Friend,
Try the following code
OOP JAVa - Java Interview Questions OOP JAVa Is java is 100% OOP.?Plz giv full explanation. hi Sanjay,dis is Srinivas(MCA from Andhra University).....Java is not an 100 % OOPL,because of the availability of Primitive Data Types
Assignment of variables - JSP-Servlet Assignment of variables How to assign a javascript variable value to a java string variable.
....
var strName="Tarunkanti Kar";
....
...
I want to access the script variable in java variable please give
oop answers - Java Beginners oop answers Consider the following declarations:
{
private int.... Write a Java statement that prints the values of the instance variables of x.
i. Write a Java statement that creates the XClass object t and initializes
OOP questions - Java Beginners OOP questions Consider the following declarations:
{
private... of a and the instance variable w is initialized to the value of b.
h. Write a Java statement that prints the values of the instance variables of x.
i. Write a Java
OOP with Java - Java Beginners OOP with Java I had a look at the solution for the answers, in the website already, but my lecturer wants us to do it in another method. Here goes the question.
Write a program to assign passengers seats in an airplane
OOP - Java Beginners
OOP i have problem with OOP hope u'll help me write a program that allows the user to enter student' names followed by their test scores and outputs...://www.roseindia.net/java/master-java/java-object-oriented-language.shtml
OOP questions - Java Beginners OOP questions Consider the following declarations:
{
private int u;
private double w;
public XClass()
{
}
public XClass(int a, double...;
}
For more information on Java visit to :
http://www.roseindia.net/java
Java assignment of variables - JSP-Servlet Javaassignment of variables
....
var strName="Tarunkanti Kar";
....
...
I want to access the script variable in java variable please give the code
java"oop" - Java Beginners Java OOPs Concept What is OOPs programming and what it has to do with the Java? Hi i hope you understand it.//To print the even numbers...){ System.out.println(e); } }}Java program to display all even numbers http
java oop - Java Beginners java oop Consider the following declarations:
{
private int u... variable w is initialized to the value of b.
h. Write a Java statement that prints the values of the instance variables of x.
i. Write a Java statement
JAVA OOP - Java Beginners JAVA OOP Employees in a company are divided into the classes Employee, HourlyPaid, Salescommissioned and Executive for the purpose of calculating their weekly wages or monthly salaries. The data to be maintained for each class
assignment of variables - JSP-Servlet assignment of variables How to assign a javascript variable value to a java string variable.
....
var strName="Tarunkanti Kar";
....
...
I want to access the script variable in java variable please give
OOP - Java Beginners
OOP Which one is better to learn object oriented progamming java or c++?
thaks,
Bet. Hello,
As of my concern both have different scope and use, you can not merge these. As i java person so i will show you java
OOP OOP
OOPs stands... the object creation process, programmatically.
Read more at :
www.roseindia.net/java/beginners/oop-in-java.shtml
OOP - Java Beginners
);
}
For more information on Java visit to :
http://www.roseindia.net/java/
http://www.roseindia.net/java/beginners/Construct.shtml
Thanks
Urgent programming assignment
Urgent programming assignment Hi,
I am an Indian student in USA.I have been able to write all the java codes successfully , however this one is giving me tremors.Any help would be highly appreciated.I am attaching
OOP Summary Java: OOP Summary
Objects
All objects are allocated... be either, but
Java supports only object references.
Assignment
Reference variable assignment is fast because only
OOP using Java - Java Beginners OOP using Java Can you write a Java statement that creates the object mysteryClock of the Clock type, and initialize the instance variables hr,min...);
}
}
For more information on Java visit to :
http://www.roseindia.net/java
OOP with Java 2 - Java Beginners OOP with Java 2 Define a class called BogEntry that could be used to store an entry for a Web log. The class should have member variables to store the poster's username, text of entry, and the date of the entry using the Date
OOP Using JAVA - Java Beginners OOP Using JAVA OBJECT ORIENTED PROGRAMMING USING JAVA
(hope guys u will help me please i need your help,thank you so much)
Create a Java program...();
oops.OopType();
}
}
For more information on Java visit to :
http
OOP with Java 3 - Java Beginners OOP with Java 3 Write a Temperature class that has two instances variables: temperature value (a floating-point number) and a character for the scale, wither C for Celsius or F for Fahrenheit. the class should have four
OOP with Java-Array - Java Beginners OOP with Java-Array Write a program to assign passengers seats in an airplane. Assume a small airplane with seat numberings as follows:
1 A B C D
2 A B C D
3 A B C D
4 A B C D
5 A B C D
6 A B C D
7
Assignment Operators in java 7 Assignment Operators in java 7
In this section you will learn about the Assignment Operators. This is one
type of operators.
Assignment Operators... to the variable by using any assignment operator. Your
variables are placed
Simple Assignment Operator
in Java that are know as compound assignment operators and can
be used with all...
Simple Assignment Operator
Assignment operator
OOP Tutorial [first draft] Java: OOP Tutorial [first draft]
Table of contents
Introduction....
These notes are about programming and Java language features necessary
for OOP, and do...-Oriented Design (OOD) and Object-Oriented Programming (OOP)
An important part
Eclipse
languages flavors, therefore a lot of users use Eclipse as a Java IDE... by including Plug-in Development Environment (PDE). Since Eclipse is
written in java, it doesn't mean that it is limited to the java language.
Eclipse supports the plug
Debug in Eclipse
Debug in Eclipse How to debug a java application in Eclipse Helio version
Object-Oriented Programming Java: Object-Oriented Programming
Beyond OOP
Here's an interesting article about going beyond OOP:
The Next Move in Programming: A Conversation with Sun's Victoria Livschitz
at java.sun.com/developer/technicalArticles/Interviews
Methods - OOP Java NotesMethods - OOP
Static methods
If your method doesn't use an object of the class it is defined in, but
does some work only....
A good example of a static methods in Java is the Math or Character
Assignment problem Assignment problem hello,
I am designing a program partaining job assingment using hungarian algorithm,but i am totally confused, please help me out
sir i,have a assignment for these question plz help me sir - JavaMail
sir i,have a assignment for these question plz help me sir
1.Design a Java interface for ADT Stack. Develop two different classes... class hierarchy in Java. Write a test program to demonstrate polymorphism