Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

INFORMATION TECHNOLOGY

PROJECT REPORT

SUBMITTED FOR

ALL INDIA SENIOR SECONDARY


SCHOOL EXAMINATION - 2022-2023
BRAIN GAMES

Done By:
R.G. Bhavadarshini
XII-C
SUBMITTED TO THE
DEPARTMENT OF INFORMATION
TECHNOLOGY
ACKNOWLEDGMENT
I would like to express my special thanks of gratitude to my teacher

Mrs. Josephine for her guidance, support throughout the duration of

the project. We completed the project successfully by her motivation

and her extended support for us.

As well as I would like to thank our Correspondent Dr. R.

Kishore Kumar, our Principal Mrs. Shanthi Samuel and Vice

Principal who gave me the opportunity to work on this project, which

in turn helped me in doing a lot of Research and analysis in the chosen

topic.

Finally, I would also like to thank my parents and friends who

supported me in completing this project within the limited time frame.


TABLE OF CONTENT

S.NO CONTENTS PAGE NO

1 Abstract 5

2 Problem Statement 6

Requirement Definition
3 7-8
Phase

4 Design Phase 9-13

5 Implementation Phase 14-31

6 Testing Phase 32-36

7 Conclusion 37

8 Future Enhancement 38
ABSTRACT
Brain games challenge your mind with fun, short games that train your

memory, focus and cognitive function. For instance, a game challenging you to

remember the placement of specific tiles on a board is an excellent memory

workout. Word games can help improve literacy and focus. Brain games work

because our brains have an inherent ability to change themselves by remodelling

nerve cell connections after experience (this ability is known as neuroplasticity).

With each game, your mind improves itself, and in the long run brain games has

shown to markedly improve overall brain function.

In adults, brain training games have been shown to workout existing grey

matter, and help stave off memory loss and dementia that comes with age. These

games have also been shown to boost the dendrites in your brain that are

responsible for processing information. So if you are concerned with maintaining

your memory and focus with age, brain games are an excellent tool to help. For

kids, the benefits of brain training may be even greater, helping improve child

literacy, numeracy and even IQ. Kids who use brain games have been

demonstrated marked academic performance as well – going from the bottom of

their class to the top, all by exercising their mind just a few extra minutes a day.
PROBLEM STATEMENT
In Brain Games, a player is given three mini-games namely:

1. Quick Math
2. Text Twist
3. Atlas

Quick Math
In this mini-game, the player has a choice of addition & subtraction or
multiplication & division. In either case the player will be given two number and
the player must perform the required arithmetic operation. 10 points for a right
answer and a negative 5 points for a wrong answer.

Text Twist
In this mini-game, the player is given a word, the player how has to form
words that has same letters as that of the word given. 10 points for a right answer
and a negative 5 points for a wrong answer.

Atlas
In this mini-game, the computer gives a place which can be a city, district,
state, country, etc. the player has to type another place which starts with the same
letter as that of the ending letter given by the computer. 10 points for a right
answer and a negative 5 points for a wrong answer.
REQUIREMENT DEFINITION PHASE

Login Page
Scope:
The login credentials given by the player is checked with the data in the
database and access is granted or rejected depending on the correctness of the
credentials given.

Feasibility:
Java Method, Java MySQL Connection, Java Exception Handling and
MySQL commands.

Quick Math
Scope:
(i) The 2 numbers that are displayed, should be random
at the same time should not be too large.
(ii) The selection of addition or subtract and
multiplication or division should be random.
(iii) The score should be updated.

Feasibility:
This mini-game needs the knowledge of Java API, Java Array, Java Method,
Java Object.

Text Twist
Scope:
(i) Words should be selected at random from the database and should
be displayed.
(ii) The words given by the player should be checked.
(iii) Scores should be updated.

Feasibility:
This mini-game needs the knowledge of Java MySQL Connection, Java
Method, Java API, Java Exception Handling, SQL DDL (Data Definition
Language) and SQL DML (Data Manipulation Language).

Atlas
Scope:
(i) A Place should be selected at random from the database and should
be displayed.
(ii) The place given by the player should be checked.
(iii) The scores should be updated.

Feasibility:
This mini-game needs the knowledge of Java MySQL Connection, Java
Method, Java API, Java Exception Handling, SQL DDL (Data Definition
Language) and SQL DML (Data Manipulation Language).
DESIGN PHASE
Map of this application is given below:

Login Page

Main Page

Quick Math Text Twist Atlas

Addition & Multiplication


Subtraction & Division

Also the following the description of the relations used as the back-end.

TABLE – atlas

S.NO NAME TYPE REMARKS

1 Place Varchar(100) Names of place such as city, country,


district, etc.

This table is used by the atlas mini-game to display a place to the player.

TABLE - userinfo
S.NO NAME TYPE REMARKS

1 UserId int Primary key and is auto increment

2 Name varchar(25) Name of the user or player

3 Password varchar(40) The corresponding password


This table is used by the login page to log into the game.

TABLE – words

S.NO NAME TYPE REMARKS

1 Word Varchar(100) Contains different words


This table is used by the Text Twist game.

The following the page structure for the front-end.

LOGIN PAGE

MAIN PAGE
QUICK MATH

Addition & Subtraction

Multiplication & Division


TEXT TWIST

ATLAS
IMPLEMENTATION PHASE

Front-End: Java Program


A project named “BrainGames” is created and the following files and coding
is setup in Java NetBeans.

BrainGames.java (java main class file under Java)

package braingames;
public static void main(String args[]){
LoginPage lp = new LoginPage();
lp.show();
}

LoginPage.java (JFrame Form under Swing GUI Form)

package braingames;
import java.sql.*;
import javax.swing.JOptionPane;
public class LoginPage extends javax.swing.JFrame {
public LoginPage() {
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// Login Button
MainPage mp = new MainPage();
try{
String id = jTextField3.getText();
Connection
dbcon=DriverManager.getConnection("jdbc:mysql://localhost:3306/brain_games", "root",
"root");
Statement st=dbcon.createStatement();
String query="select * from UserInfo where UserId="+id;
ResultSet rs=st.executeQuery(query);
rs.next();
String pwd=rs.getString("password");
if(pwd.equals(jPasswordField1.getText())){
mp.show();
dispose();
}
else{
JOptionPane.showMessageDialog(null," incorrect Password");
}
}catch(SQLException ex)
{
System.out.println(ex.getMessage());
}catch(Exception e){
System.out.println(e.getMessage());
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// Exit button
System.exit(0);
}
Auto Generated codes
}

MainPage.java (JFrame Form under Swing GUI Form)


package braingames;
public class MainPage extends javax.swing.JFrame {
public MainPage() {
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// Quick math button
QuickMath qm=new QuickMath();
qm.show();
dispose();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// Text Twist button
TextTwist tt=new TextTwist();
tt.show();
dispose();
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// Atlas button:
Atlas a=new Atlas();
a.show();
dispose();
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// Exit button:
System.exit(0);
}
}

QuickMath.java (JFrame Form under Swing GUI Form)


package braingames;
public class QuickMath extends javax.swing.JFrame {
public QuickMath() {
initComponents();
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// Exit button:
System.exit(0);
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// Main Pagebutton:
MainPage mp = new MainPage();
mp.show();
dispose();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// Addition & Subtraction Page button:
AddSub as = new AddSub();
as.show();
dispose();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// Multiplication & Division Page button:
MulDiv md = new MulDiv();
md.show();
dispose();
}
Auto Generated codes
}

AddSub.java (JFrame Form under Swing GUI Form)

package braingames;
import java.util.Random;
import javax.swing.JOptionPane;
public class AddSub extends javax.swing.JFrame {
int i;
void CorrectNext(){
jTextField4.setText(String.valueOf(Integer.valueOf(jTextField4.getText()) + 10));
jTextField3.setText("");
String[] symbol = {"+" , "-"};
Random rm = new Random();
i = rm.nextInt(symbol.length);
jLabel2.setText(symbol[i]);
jTextField1.setText(String.valueOf((int) (Math.random() * 100)));
jTextField2.setText(String.valueOf((int) (Math.random() * 100)));
}
void WrongNext(){
jTextField4.setText(String.valueOf(Integer.valueOf(jTextField4.getText()) - 5));
jTextField3.setText("");
JOptionPane.showMessageDialog(null, "opps! incorrect answer");
String[] symbol = {"+" , "-"};
Random rm = new Random();
i = rm.nextInt(symbol.length);
jLabel2.setText(symbol[i]);
jTextField1.setText(String.valueOf((int) (Math.random() * 100)));
jTextField2.setText(String.valueOf((int) (Math.random() * 100)));
}
public AddSub() {
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// Start button
jLabel3.setText("=");
jTextField4.setText("0");
String[] symbol = {"+" , "-"};
Random rm = new Random();
i = rm.nextInt(symbol.length);
jLabel2.setText(symbol[i]);
jTextField1.setText(String.valueOf((int) (Math.random() * 100)));
jTextField2.setText(String.valueOf((int) (Math.random() * 100)));
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// check button

try{
int ans = Integer.valueOf(jTextField3.getText());
int num1 = Integer.valueOf(jTextField1.getText());
int num2 = Integer.valueOf(jTextField2.getText());
Random rm = new Random();
if(i==0){
if(num1+num2==ans){
CorrectNext();
}
else{
WrongNext();
}
}
else{
if((num1-num2) == ans){
CorrectNext();
}
else{
WrongNext();
}

}
}catch(NumberFormatException e){
JOptionPane.showMessageDialog(null, "please type an answer");
System.out.println(e.getMessage());
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// back button
QuickMath qm = new QuickMath();
qm.show();
dispose();
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// back to main page
MainPage mp = new MainPage();
mp.show();
dispose();
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// exit
System.exit(0);
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// restart
jTextField3.setText("");
jTextField4.setText("0");
jLabel3.setText("=");
String[] symbol = {"+" , "-"};
Random rm = new Random();
i = rm.nextInt(symbol.length);
jLabel2.setText(symbol[i]);
jTextField1.setText(String.valueOf((int) (Math.random() * 100)));
jTextField2.setText(String.valueOf((int) (Math.random() * 100)));
}
Auto Generated code
}
MulDiv.java (JFrame Form under Swing GUI Form)

package braingames;
import java.util.Random;
import javax.swing.JOptionPane;
public class MulDiv extends javax.swing.JFrame {
int i,j;
public MulDiv() {
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// Start button
jLabel3.setText("=");
String[] symbol = {"X" , "/"};
Random rm = new Random();
i = rm.nextInt(symbol.length);
j = (int) (Math.random() * 20);
jLabel2.setText(symbol[i]);
if(jLabel2.getText().equals("/")){
jLabel5.setVisible(true);
jTextField5.setVisible(true);
while(j==0){
j = (int) (Math.random() * 20);
}
}
else{
jLabel5.setVisible(false);
jTextField5.setVisible(false);
}
jTextField1.setText(String.valueOf((int) (Math.random() * 20)));
jTextField2.setText(String.valueOf(j));
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// check button:

try{
int ans = Integer.valueOf(jTextField3.getText());
int num1 = Integer.valueOf(jTextField1.getText());
int num2 = Integer.valueOf(jTextField2.getText());
Random rm = new Random();
if(i==0){
if(num1*num2==ans){
jTextField4.setText(String.valueOf(Integer.valueOf(jTextField4.getText()) + 10));
jTextField3.setText("");
String[] symbol = {"X" , "/"};
i = rm.nextInt(symbol.length);
j = (int) (Math.random() * 20);
jLabel2.setText(symbol[i]);
if(jLabel2.getText().equals("/")){
jLabel5.setVisible(true);
jTextField5.setVisible(true);
while(j==0){
j = (int) (Math.random() * 20);
}
}
else{
jLabel5.setVisible(false);
jTextField5.setVisible(false);
}
jTextField1.setText(String.valueOf((int) (Math.random() * 20)));
jTextField2.setText(String.valueOf(j));
}
else{
jTextField4.setText(String.valueOf(Integer.valueOf(jTextField4.getText()) - 5));
jTextField3.setText("");
String[] symbol = {"X" , "/"};
i = rm.nextInt(symbol.length);
j = (int) (Math.random() * 20);
jLabel2.setText(symbol[i]);
if(jLabel2.getText().equals("/")){
jLabel5.setVisible(true);
jTextField5.setVisible(true);
while(j==0){
j = (int) (Math.random() * 20);
}
}
else{
jLabel5.setVisible(false);
jTextField5.setVisible(false);
}
jTextField1.setText(String.valueOf((int) (Math.random() * 20)));
jTextField2.setText(String.valueOf(j));
JOptionPane.showMessageDialog(null, "opps! incorrect answer");
}
}
else{
if((num1/num2) == ans && (num1%num2) ==
Integer.valueOf(jTextField5.getText())){
jTextField3.setText("");
jTextField5.setText("");
jTextField4.setText(String.valueOf(Integer.valueOf(jTextField4.getText()) + 10));
String[] symbol = {"X" , "/"};
i = rm.nextInt(symbol.length);
j = (int) (Math.random() * 20);
jLabel2.setText(symbol[i]);
if(jLabel2.getText().equals("/")){
jLabel5.setVisible(true);
jTextField5.setVisible(true);
while(j==0){
j = (int) (Math.random() * 20);
}
}
else{
jLabel5.setVisible(false);
jTextField5.setVisible(false);
}
jTextField1.setText(String.valueOf((int) (Math.random() * 20)));
jTextField2.setText(String.valueOf(j));
}
else{
jTextField4.setText(String.valueOf(Integer.valueOf(jTextField4.getText()) - 5));
jTextField3.setText("");
jTextField5.setText("");
String[] symbol = {"X" , "/"};
i = rm.nextInt(symbol.length);
j = (int) (Math.random() * 20);
jLabel2.setText(symbol[i]);
if(jLabel2.getText().equals("/")){
jLabel5.setVisible(true);
jTextField5.setVisible(true);
while(j==0){
j = (int) (Math.random() * 20);
}
}
else{
jLabel5.setVisible(false);
jTextField5.setVisible(false);
}
jTextField1.setText(String.valueOf((int) (Math.random() * 20)));
jTextField2.setText(String.valueOf(j));
JOptionPane.showMessageDialog(null, "opps! incorrect answer");
}

}
}catch(NumberFormatException e){
JOptionPane.showMessageDialog(null, "please type an answer");
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// back button:
QuickMath qm = new QuickMath();
qm.show();
dispose();
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// Back to main page:
MainPage mp = new MainPage();
mp.show();
dispose();
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// restart button:
jTextField3.setText("");
jTextField4.setText("0");
jTextField5.setText("");
jLabel3.setText("=");
String[] symbol = {"X" , "/"};
Random rm = new Random();
i = rm.nextInt(symbol.length);
j = (int) (Math.random() * 20);
jLabel2.setText(symbol[i]);
if(jLabel2.getText().equals("/")){
jLabel5.setVisible(true);
jTextField5.setVisible(true);
while(j==0){
j = (int) (Math.random() * 20);
}
}
else{
jLabel5.setVisible(false);
jTextField5.setVisible(false);
}
jTextField1.setText(String.valueOf((int) (Math.random() * 20)));
jTextField2.setText(String.valueOf(j));
}
Auto generated code
}
TextTwist.java (JFrame Form under Swing GUI Form)

package braingames;
import java.sql.*;
import javax.swing.JOptionPane;
public class TextTwist extends javax.swing.JFrame {
public TextTwist() {
initComponents();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// back to main page:
MainPage mp = new MainPage();
mp.show();
dispose();
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// start:
try {
Connection
dbcon=DriverManager.getConnection("jdbc:mysql://localhost:3306/brain_games", "root",
"root");
Statement st=dbcon.createStatement();
String w="select * from words order by rand() limit 1";
ResultSet wo=st.executeQuery(w);
wo.next();
String word1=wo.getString("word");
jTextField1.setText(word1);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// check:
String a=jTextField3.getText();
String b=jTextField4.getText();
String c=jTextField5.getText();
String d=jTextField6.getText();
String e=jTextField7.getText();
String f=jTextField8.getText();
String ans=jTextField1.getText();
if(ans.contains(a) && ans.contains(b) && ans.contains(c) && ans.contains(d) &&
ans.contains(e) && ans.contains(f)){
jTextField9.setText(String.valueOf(Integer.valueOf(jTextField9.getText()) + 10));
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");
jTextField6.setText("");
jTextField7.setText("");
jTextField8.setText("");
String word;
try {
Connection
dbcon=DriverManager.getConnection("jdbc:mysql://localhost:3306/brain_games", "root",
"root");
Statement st=dbcon.createStatement();
String w="select * from words order by rand() limit 1";
ResultSet wo=st.executeQuery(w);
wo.next();
word=wo.getString("word");
jTextField1.setText(word);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
else{
jTextField9.setText(String.valueOf(Integer.valueOf(jTextField9.getText()) - 5));
JOptionPane.showMessageDialog(null, "Opps !!! Your answer is Wrong");
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");
jTextField6.setText("");
jTextField7.setText("");
jTextField8.setText("");
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// exit:
System.exit(0);
}
Auto generated code
}

Atlas.java (JFrame Form under Swing GUI Form)

package braingames;
import java.sql.*;
public class Atlas extends javax.swing.JFrame {
public Atlas() {
initComponents();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// back to main page:
MainPage mp = new MainPage();
mp.show();
dispose();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//play (or) play again
jButton1.setText("Play Again");
jTextField4.setText("0");
try {
Connection
dbcon=DriverManager.getConnection("jdbc:mysql://localhost:3306/brain_games", "root",
"root");
Statement st=dbcon.createStatement();
String a="select place from atlas order by rand() limit 1";
ResultSet at=st.executeQuery(a);
at.next();
String val1=at.getString("place");
jTextField1.setText(val1);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
try {
// next:
String a = jTextField1.getText().toLowerCase();
char a1 = a.charAt((a.length())-1);
String b = jTextField2.getText().toLowerCase();
char b1 = b.charAt(0);
Connection
dbcon=DriverManager.getConnection("jdbc:mysql://localhost:3306/brain_games", "root",
"root");
Statement st=dbcon.createStatement();
if(a1 ==b1){
jTextField4.setText(String.valueOf(Integer.valueOf(jTextField4.get Text()) + 10));
ResultSet word=st.executeQuery("select place from atlas order by rand() limit 1");
word.next();
jTextField1.setText(word.getString("place"));
jTextField2.setText("");
}
else{
jTextField4.setText(String.valueOf(Integer.valueOf(jTextField4.getText()) - 5));
ResultSet word=st.executeQuery("select place from atlas order by rand() limit 1");
word.next();
jTextField1.setText(word.getString("place"));
jTextField2.setText("");
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
} catch (Exception e){
System.out.println(e.getMessage());
}
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// exit:
System.exit(0);
}
Auto Generated code
}

Back-End: MySQL
The following quires are used to create a database and tables, and sample
data is inserted.

create database brain_games;


use brain_games;
create table words(word varchar(100) primary key);
create table UserInfo(UserId int primary key auto_increment, Name varchar(40));

now the Data Connectivity is established between Java and MySQL.

TESTING PHASE
On running the project, the main file i.e. BrainGames.java is run, and the
login page is opened

After the entry of login credentials, the main page of the game is open where
there are three sets of game to choose from,

On clicking quick math, the quick page is open as shown in the design phase.
Now on clicking Addition & Subtraction and clicking on start button,

On typing a right answer, next quesiton is displayed and a score of 10 is


incremented,
And on typing a wrong answer, a dialog box is shown and a score of 5 is
decremented.

Going back to the Quick Math page using the back button and clicking
multiplication or division followed by start button, the answer is typed
On checking using the check button, the score is incremented to 10 and the
next question is in multiplication, here the remainder text field and its label is
removed,

Now going back to the main page and clicking on Text Twist followed by
clicking the start button,
Now the answer is typed in the boxed and checked,

The score is incremented and the next question is displayed.

Now going back to main page and then to atlas (and clicking play), the
question is displayed

Since the last letter of is ‘A’ (as in Varna) the answer is typed
Since the input is correct the score is incremented and the next place is
displayed.

Thus all the parts of coding are tested and bugs are debugged.
CONCLUSION
Brain games show a higher improvement in mental performance and

problem-solving skills than those who do not. This is not entirely unexpected

considering that video games simulate and provide problems that are fun to solve,

allowing people to enjoy learning new skills that can be applied in real life

situations.

It is interesting to note that, Proponents of brain training hark back to the

original cabbie studies and MRI studies showing growth of their hippocampi, as

well as other research showing that after brain training, EEG reports showed that

specific types of brain training changed brain activity. But the training involved

showed no improvement in cognitive performance outside of the trained task, and

were the very same changes seen following any type of learning: playing a game

may change neural systems, but so too does studying a new language or taking

up an instrument.
FUTURE ENHANCEMENT
In the future, the brain game can be improved in aspects of using timers and

timed scores, timers were not added to these game as it is beyond the knowledge.

Other mini games such as “guess the colour”, “memory game”, “connect the

dots” “colour not the word” and many more games can be added to the list.

As we can also add animations for brain games like chess, cards and

colourful puzzles etc. in this using java as its beyond our knowledge we can

achieve doing that in future.

As technology advances, we will see games become a completely immersive

experience. Imagine fully encompassing make-believe worlds that you control

with your mind and body. Advances in technology and the rapid growth of the

brain games.

You might also like