Game tic tac project

download Game tic tac project

of 43

Transcript of Game tic tac project

  • 7/23/2019 Game tic tac project

    1/43

    TIC-TAC-TOE GAME

    M.C.A(Master of ComputerApplications)

    THREE YEAR COURE (!t"EMETER)#$%&

    u'mitte To- u'mitte*+-,rof. Amritpal in" Ra"ul

    etiau"preet /aur

    Yaa0inra CO11EGE O2 E3GG.TA14A35I A*O (*ATHI35A)

    A6liate to,U37A*I U3I8ERITY ,ATIA1A

  • 7/23/2019 Game tic tac project

    2/43

    TIC-TAC-TOEGAME

    M.C.A (Master of ComputerApplications)

    THREE YEAR COURE (!t"EMETER)#$%&

    u'mitte To- u'mitte*+-

    ,rof. Amritpal in" Ra"ul etiau"preet /aur

    YA5A8I35RA CO11EGE O2 E3GG.TA14A35I A*O (*ATHI35A)

    a6liate to - pun9a'i uni0ersit+ patiala

  • 7/23/2019 Game tic tac project

    3/43

  • 7/23/2019 Game tic tac project

    4/43

    CERTI2ICATE

    T"is is "ere '+ certi=e t"at t"e pro9ect

    report of >Tic-Tac-Toe Game? "as 'een

    complete uner m+ super0ision '+ Ra"ul

    etia (#@@) B u"preet /aur (#@&) of

    MCA 2ourt" em at Yaa0inra Collee of

    En.; Tal:ani a'o (*at"ina) a6liate to

    ,un9a'i Uni0ersit+; ,atiala in t"e session

    #$%!-%&. T"e :or one is t"e pro9ect is t"e

    result caniates o:n eDorts.

    ,rof.Amritpal in"

    Yaa0inra Collee of En.

    Tal:ani a'o (*at"ina)

  • 7/23/2019 Game tic tac project

    5/43

    5EC1ARATIO3

    T"is is to certif+ t"at t"e pro9ect

    report title >TIC-TAC-TOE GAME? is :or

    of stuents RAHU1 ETIA an U/H,REET/AUR stuent of MCA (Master of

    Computer Applications) T"ree Year Course

    !t" em at YA5A8I35RA CO11EGE O2

    E3GG.; TA14A35I A*O (*ATHI35A)

    3o part of t"is report "as 'eensu'mitte to an+ ot"er collee uni0ersit+

    for t"e re:ar of an+ eree to t"e 'est

    of m+ no:lee.

    u"preet /aur

  • 7/23/2019 Game tic tac project

    6/43

    Java language

    Java is an object-oriented programming language with a built-in application

    programming interface (API) that can handle graphics and user interfaces and that can be

    used to create applications or applets. Because of its rich set of APIs! similar to

    "acintosh and #indows! and its platform independence! Java can also be thought of as a

    platform in itself. Java also has standard libraries for doing mathematics! some familiarit$

    with the s$nta% of &'& is useful.

    In Java we distinguish between applications! which are programs that perform the

    same functions as those written in other programming languages! and applets! which are

    programs that can be embedded in a #eb page and accessed over the Internet. ur initial

    focus will be on writing applications. #hen a program is compiled! a b$te code is

    produced that can read and e%ecuted b$ an$ platform that can run Java.

    FEATURES OF JAVA

    Although the fundamental forces that necessitated the invention of Java are portabilit$

    and securit$! other factors also pla$ed an important role in molding the final form of thelanguage. *he +e$ considerations were summed up b$ the Java team in following list of

    bu,,words

    1. Security

    #hen we use a Java-compatible #eb browser! we can safel$ download Java applets

    without fear of viral infection or malicious intent. Java achieves this protection b$confining a Java program to the Java e%ecution environment and not allowing it access to

    other parts of the computer. *he abilit$ to download applets with confidence that no harm

    will be done and that no securit$ will be breached is considered b$ man$ to be the singlemost important aspect of Java.

    2. Portability

    "an$ t$pes of computers and operating s$stems are in use throughout the world andman$ are connected to the Internet. or programs to be d$namicall$ downloaded to allthe various t$pes of platforms connected to the Internet! some means of generating

    portable e%ecutable code is needed. As $ou will soon see! the same mechanism that helps

    ensure securit$ also helps create portabilit$. Indeed! Javas solution to these two problemsis both the elegant and efficient.

    3. Simle

    Java was designed to be eas$ for the professional programmer to learn use

    effectivel$. Assuming that $ou have some programming e%perience! $ou will not find

    Java hard to master. If $ou alread$ understand the basic concepts of object-oriented

    programming! learning Java will be even easier.!. Ob"ect#Oriente$

    Although influenced b$ its predecessors! Java was not designed to be source-code

    compatible with an$ other language. *his allowed the Java team the freedom to design

    with a blan+ slate. ne outcome of this was a clean! usable! pragmatic approach to

    objects. Borrowing liberall$ from man$ seminal object-software environments of the last

    few decades.

  • 7/23/2019 Game tic tac project

    7/43

    %. Robu&t

    *he multiplatform environment of the #eb places e%traordinar$ demands on a

    program! because the program must e%ecute reliabl$ in a variet$ of s$stems. *hus! the

    abilit$ to create robust programs was given a high priorit$ in the design of Java. *o gain

    reliabilit$! Java restricts $ou in a few +e$ areas! to force $ou to find $our mista+es earl$

    in program development. At the same time! Java frees $ou from having to worr$ about

    man$ of the most common causes of programming errors. Because Java is a strictl$ t$ped

    language! it chec+s $our code at compile time. /owever! it also chec+s $our code at

    runtime.

    '. (ultit)rea$e$

    Java was designed to meet the real-world re0uirement of creating interactive!

    networ+ed programs. *o accomplish this! Java supports multithreaded programming!

    which allows $ou to write programs that do man$ things simultaneousl$. *he Java run-

    time s$stem comes with an elegant $et sophisticated solution for multiprocessor

    s$nchroni,ation that enables $ou to construct smoothl$ running interactive s$stems.Javas eas$-to-use approach to multithreading allows $ou to thin+ about the specific

    behavior of $our program! not the multitas+ing subs$stem.

    *. Arc)itecture#+eutral

    A central issue for the Java designers was that of code longevit$ and portabilit$. ne

    of the main problems facing programmers is that no guarantee e%ists that if $ou write a

    program toda$! it will run tomorrow- even on the same machine. perating s$stem

    upgrades! process upgrades! and and change in core s$stem resource can all combine to

    ma+e a program malfunction. *he Java designers made several hard decisions in the Java

    language and the Java 1irtual "achine in an attempt to alter this situation. *heir goal was

    2#rite once3 4un an$where! an$ time! forever. 5 *o a great e%tent! this goal wasaccomplished.

    ,. -nterrete$ an$ ig) Per/ormance

    Java enables the creation of cross-platform programs b$ compiling into intermediate

    representations called Java b$te code. *his code can be interpreted on an$ s$stem that

    provides a Java 1irtual "achine. "ost previous attempts at cross-platform solutions have

    done so at the e%pense of performance.

    0. i&tribute$

    Java is designed for the distributed environment of the internet! because it handles

    *&P'IP protocols. In fact! accessing a resource using a 647 is not much different from

    accessing a file. *he original version of Java(a+) included features for intra address-

    space messaging. *his allowed objects all to different computers to e%ecute procedures

    remotel$.

    1. ynamic

    Java programs carr$ with them substantial amounts of runtime t$pe information that

    is used to verif$ and resolve accesses to objects at run time. *his ma+es it possible to

    d$namicall$ lin+ code in a safe and e%pedient manner. *his is crucial to the robustness of

  • 7/23/2019 Game tic tac project

    8/43

    the applet environment! in which small fragments of b$te-code ma$ be d$namicall$

    updated on a running s$stem.

  • 7/23/2019 Game tic tac project

    9/43

    onclu&ion

    *he project was successfull$ completed after a lot of efforts 8 wor+ hours. #e have

    carefull$ studied and anal$,ed each and ever$ module of software and have tried to

    solve it. *he s$stem has been developed for the given condition and is found wor+ing

    effectivel$. *he developed s$stem is fle%ible and changes whenever can be made eas$.

    6sing the facilities and functionalities of Java! the software have been developed in a

    neat and simple manner! thereb$ reducing the operators wor+. *he speed and accurac$

    are maintained in proper wa$. *he user friendl$ nature of the software developed in Java

    language is ver$ eas$ to wor+ with both for the higher management as well as other

    emplo$ees with little +nowledge of computer. *he result obtained were full$ satisfactor$

    from the user point of view. *he s$stem was verified with valid as well as invalid data in

    each manner. *he s$stem is run with an insight into the necessar$ modifications that ma$

    re0uired in the future. /ence the s$stem can be maintained successfull$ without much

    networ+. Its hard to develop the perfect s$stem in the ver$ first effort. But our

    satisfaction becomes more that we have submitted this project in time.

    9u+hpreet :aur

  • 7/23/2019 Game tic tac project

    10/43

  • 7/23/2019 Game tic tac project

    11/43

    pacae ameF

    pu'lic class Game

    pu'lic static 0oi main(trin ars)

    JJ

  • 7/23/2019 Game tic tac project

    12/43

    package game;

    public class GameForm extends javax.swing.JFrame {

    public GameForm() {

    initComponents();

    ! "#is met#od is called $rom wit#in t#e constructor to initiali%e t#e

    $orm.

    ! &'*G+ ,o -" modi$ t#is code. "#e content o$ t#is met#od is

    alwas

    ! regenerated b t#e Form /ditor.

    !0

    12uppress&arnings(3unc#ecked3) 00 4editor5$old de$aultstate63collapsed3 desc63Generated Code37

    private void initComponents() {

    lbl8 6 new javax.swing.J9abel();

    lbl: 6 new javax.swing.J9abel();

    lbl 6 new javax.swing.J9abel();

    lbl< 6 new javax.swing.J9abel();

    lbl= 6 new javax.swing.J9abel();

    lbl> 6 new javax.swing.J9abel();

    lbl? 6 new javax.swing.J9abel(); lbl@ 6 new javax.swing.J9abel();

    lblA 6 new javax.swing.J9abel();

    lblr 6 new javax.swing.J9abel();

    btnew 6 new javax.swing.JButton();

    jButton: 6 new javax.swing.JButton();

    set,e$aultClose-peration(javax.swing.&indowConstants./*"D-D

    C9-2/);

    lbl8.setBackground(new java.awt.Color(:E

  • 7/23/2019 Game tic tac project

    13/43

    lbl8Clicked(evt);

    );

    lbl:.setBackground(new java.awt.Color(

  • 7/23/2019 Game tic tac project

    14/43

    );

    lbl>.setBackground(new java.awt.Color(:E

  • 7/23/2019 Game tic tac project

    15/43

    btnew.setFont(new java.awt.Font(3Comic 2ans 23 : :?)); 00

    -*:A

    btnew.set"ext(3ew Game3);

    btnew.addouse9istener(new java.awt.event.ouse'dapter() {

    public void mouseClicked(java.awt.event.ouse/vent evt) {

    ewClicked(evt);

    );

    jButton:.setFont(new java.awt.Font(3Comic 2ans 23 : :?)); 00

    -*:A

    jButton:.set"ext(3B'CH3);

    jButton:.add'ction9istener(new java.awt.event.'ction9istener() {

    public void actionIer$ormed(java.awt.event.'ction/vent evt) {

    jButton:'ctionIer$ormed(evt);

    );

    javax.swing.Group9aout laout 6 new

    javax.swing.Group9aout(getContentIane());

    getContentIane().set9aout(laout);

    laout.setori%ontalGroup(

    laout.createIarallelGroup(javax.swing.Group9aout.'lignment.9/'

    ,*G) .addGroup(javax.swing.Group9aout.'lignment."'*9*G

    laout.create2eKuentialGroup()

    .addContainerGap(javax.swing.Group9aout.,/F'L9"D2*M/

    2#ort.'DN'9L/)

    .addComponent(lbl:

    javax.swing.Group9aout.I/F//,D2*M/ >E

    javax.swing.Group9aout.I/F//,D2*M/)

    .addIre$erredGap(javax.swing.9aout2tle.ComponentIlacement.L

    /9'"/,)

    .addComponent(lbl

    javax.swing.Group9aout.I/F//,D2*M/ >E

    javax.swing.Group9aout.I/F//,D2*M/)

    .addIre$erredGap(javax.swing.9aout2tle.ComponentIlacement.L

    /9'"/,)

  • 7/23/2019 Game tic tac project

    16/43

    .addComponent(lbl8

    javax.swing.Group9aout.I/F//,D2*M/ >E

    javax.swing.Group9aout.I/F//,D2*M/)

    .addGap(:=? :=? :=?))

    .addGroup(laout.create2eKuentialGroup()

    .addGroup(laout.createIarallelGroup(javax.swing.Group9aout.'lig

    nment.9/',*G)

    .addGroup(laout.create2eKuentialGroup()

    .addGap(:>@ :>@ :>@)

    .addGroup(laout.createIarallelGroup(javax.swing.Group9aout.'lig

    nment.9/',*G $alse)

    .addGroup(laout.create2eKuentialGroup()

    .addComponent(lbl>javax.swing.Group9aout.I/F//,D2*M/ >E

    javax.swing.Group9aout.I/F//,D2*M/)

    .addIre$erredGap(javax.swing.9aout2tle.ComponentIlacement./

    9'"/, javax.swing.Group9aout.,/F'L9"D2*M/

    2#ort.'DN'9L/)

    .addComponent(lblA

    javax.swing.Group9aout.I/F//,D2*M/ >E

    javax.swing.Group9aout.I/F//,D2*M/)

    .addIre$erredGap(javax.swing.9aout2tle.ComponentIlacement.L

    /9'"/,)

    .addComponent(lbl@

    javax.swing.Group9aout.I/F//,D2*M/ >E

    javax.swing.Group9aout.I/F//,D2*M/))

    .addGroup(laout.create2eKuentialGroup()

    .addComponent(lbl?

    javax.swing.Group9aout.I/F//,D2*M/ >E

    javax.swing.Group9aout.I/F//,D2*M/)

    .addIre$erredGap(javax.swing.9aout2tle.ComponentIlacement.L

    /9'"/,)

    .addComponent(lblE

    javax.swing.Group9aout.I/F//,D2*M/)

  • 7/23/2019 Game tic tac project

    17/43

    .addIre$erredGap(javax.swing.9aout2tle.ComponentIlacement.L

    /9'"/,)

    .addComponent(lbl=

    javax.swing.Group9aout.I/F//,D2*M/ >E

    javax.swing.Group9aout.I/F//,D2*M/))))

    .addGroup(laout.create2eKuentialGroup()

    .addGap(?: ?: ?:)

    .addComponent(lblr))

    .addGroup(laout.create2eKuentialGroup()

    .addGap(:=> :=> :=>)

    .addComponent(btnew)

    .addGap(:

    javax.swing.Group9aout.I/F//,D2*M/)

    .addComponent(lbl8

    javax.swing.Group9aout.I/F//,D2*M/ >:

    javax.swing.Group9aout.I/F//,D2*M/)

    .addComponent(lbl:

    javax.swing.Group9aout.I/F//,D2*M/ >:

    javax.swing.Group9aout.I/F//,D2*M/))

  • 7/23/2019 Game tic tac project

    18/43

    .addIre$erredGap(javax.swing.9aout2tle.ComponentIlacement.L

    /9'"/,)

    .addGroup(laout.createIarallelGroup(javax.swing.Group9aout.'lig

    nment.B'2/9*/)

    .addComponent(lbl:

    javax.swing.Group9aout.I/F//,D2*M/)

    .addComponent(lbl=

    javax.swing.Group9aout.I/F//,D2*M/ >:

    javax.swing.Group9aout.I/F//,D2*M/)

    .addComponent(lbl?

    javax.swing.Group9aout.I/F//,D2*M/ >:

    javax.swing.Group9aout.I/F//,D2*M/))

    .addIre$erredGap(javax.swing.9aout2tle.ComponentIlacement.L

    /9'"/,)

    .addGroup(laout.createIarallelGroup(javax.swing.Group9aout.'lig

    nment.B'2/9*/)

    .addComponent(lbl>

    javax.swing.Group9aout.I/F//,D2*M/ >:

    javax.swing.Group9aout.I/F//,D2*M/)

    .addComponent([email protected]/F//,D2*M/ >:

    javax.swing.Group9aout.I/F//,D2*M/)

    .addComponent(lblA

    javax.swing.Group9aout.I/F//,D2*M/ >:

    javax.swing.Group9aout.I/F//,D2*M/))

    .addIre$erredGap(javax.swing.9aout2tle.ComponentIlacement./

    9'"/, @? 2#ort.'DN'9L/)

    .addComponent(lblr)

    .addGap(8@ 8@ 8@))

    );

    pack();

    00 40editor5$old7

    public int c#eck:(int i)

    {

  • 7/23/2019 Game tic tac project

    19/43

    i$((lbl:.get"ext() 663 -3 OO lbl.get"ext() 66 3 -3 OO lbl8.get"ext() 66 3

    -3)

    PP (lbl:.get"ext() 663 -3 OO lbl?.get"ext() 66 3 -3 OO lbl>.get"ext() 66 3

    -3)

    PP (lbl:.get"ext() 663 -3 OO lbl

  • 7/23/2019 Game tic tac project

    20/43

    PP(lbl8.get"ext() 663 3 OO lbl=.get"ext() 66 3 3 OO [email protected]"ext() 66 3

    3)

    PP (lbl?.get"ext() 663 3 OO lbl.get"ext() 663 3 OO lblA.get"ext() 66 3 3 OO [email protected]"ext() 66 3

    3))

    {

    lblr.set"ext(3Computer &in......... Ilease "r 'gain3);

    public void Computer"urn() {

    i$( ((lbl:.get"ext() 663 -3 OO lbl.get"ext() 66 3 -3 OO lbl8.get"ext() Q6

    3 3)

    PP (lbl8.get"ext() 66 3 -3 OO lbl.get"ext() 66 3 -3 OO

    lbl:.get"ext() Q6 3 3)

    PP(lbl:.get"ext() 66 3 -3OO lbl8.get"ext() 66 3 -3 OO lbl.get"ext() Q

    6 3 3))

    PP ( (lbl:.get"ext() 663 3 OO lbl.get"ext() 66 3 3 OO

    lbl8.get"ext() Q6 3 -3)

    PP (lbl8.get"ext() 66 3 3 OO lbl.get"ext() 66 3 3 OO lbl:.get"ext() Q6 3 -3)

    PP(lbl:.get"ext() 66 3 3OO lbl8.get"ext() 66 3 3 OO lbl.get"ext() Q6

    3 -3)))

    {

    i$(lbl:.get"ext()6633)

    lbl:.set"ext(3 3);

    else

    i$(lbl.get"ext()6633)

    lbl.set"ext(3 3);

    else i$ (lbl8.get"ext()6633)

    lbl8.set"ext(3 3);

    c#eck();

    return;

    i$( ((lbl?.get"ext() 663 -3 OO lbl

  • 7/23/2019 Game tic tac project

    21/43

    PP (lbl.get"ext() Q6 3 3) PP(lbl>.get"ext() 66 3 -3OO [email protected]"ext() 66 3 -3 OO lblA.get"ext() Q

    6 3 3))

    PP((lbl>.get"ext() 663 3 OO lblA.get"ext() 66 3 3 OO [email protected]"ext()

    Q6 3 -3)

    PP (lblA.get"ext() 66 3 3 OO [email protected]"ext() 66 3 3 OO lbl>.get"ext() Q

    6 3 -3)

  • 7/23/2019 Game tic tac project

    22/43

  • 7/23/2019 Game tic tac project

    23/43

    PP(lbl>.get"ext() 66 3 3OO [email protected]"ext() 66 3 3 OO lblA.get"ext() Q6 3 -3)))

    {

    i$(lbl>.get"ext()6633)

    lbl>.set"ext(3 3);

    else

    i$(lblA.get"ext()6633)

    lblA.set"ext(3 3);

    else i$ ([email protected]"ext()6633)

    [email protected]"ext(3 3);

    c#eck();

    return;

    i$( ((lbl:.get"ext() 663 -3 OO lbl?.get"ext() 66 3 -3 OO lbl>.get"ext() Q6 3 3)

    PP (lbl?.get"ext() 66 3 -3 OO lbl>.get"ext() 66 3 -3 OO lbl:.get"ext() Q6 3 3)

    PP(lbl:.get"ext() 66 3 -3OO lbl>.get"ext() 66 3 -3 OO lbl?.get"ext() Q6 3 3))

    PP ((lbl:.get"ext() 663 3 OO lbl?.get"ext() 66 3 3 OO lbl>.get"ext() Q6 3 -3)

    PP (lbl?.get"ext() 66 3 3 OO lbl>.get"ext() 66 3 3 OO lbl:.get"ext() Q6 3 -3)

    PP(lbl:.get"ext() 66 3 3OO lbl>.get"ext() 66 3 3 OO lbl?.get"ext() Q6 3 -3))) {

    i$(lbl:.get"ext()6633)

    lbl:.set"ext(3 3);

    else

    i$(lbl?.get"ext()6633)

    lbl?.set"ext(3 3);

    else i$ (lbl>.get"ext()6633)

    lbl>.set"ext(3 3);

    c#eck();

    return;

    i$( ((lbl.get"ext() 663 -3 OO lbl

  • 7/23/2019 Game tic tac project

    24/43

    PP((lbl8.get"ext() 663 3 OO lbl=.get"ext() 66 3 3 OO [email protected]"ext() Q6 3 R3)

    PP (lbl=.get"ext() 66 3 3 OO [email protected]"ext() 66 3 3 OO lbl8.get"ext() Q6 3 R3)

    PP(lbl8.get"ext() 66 3 3OO [email protected]"ext() 66 3 3 OO lbl=.get"ext() Q6 3 R3)))

    {

    i$(lbl8.get"ext()6633)

    lbl8.set"ext(3 3);

    else

    i$(lbl=.get"ext()6633)

    lbl=.set"ext(3 3);

    else i$ ([email protected]"ext()6633)

    [email protected]"ext(3 3);

    c#eck();

    return;

    i$( ((lbl:.get"ext() 663 -3 OO lbl.get"ext() Q6 3 -3)

    PP (lbl.get"ext()6633)

    lbl>.set"ext(3 3);

    c#eck();

    return;

  • 7/23/2019 Game tic tac project

    25/43

    i$(lbl.get"ext()66 33)

    {

    lbl>.set"ext(3 3);

    else i$(lbl:.get"ext()66 33)

    {

    lbl:.set"ext(3 3);

    else i$([email protected]"ext()66 33) {

    [email protected]"ext(3 3);

    else i$(lbl.get"ext()66 33)

    {

    lbl.set"ext(3 3);

    else i$(lbl?.get"ext()66 33)

    {

    lbl?.set"ext(3 3);

    else i$(lbl=.get"ext()66 33)

    {

    lbl=.set"ext(3 3);

    else i$(lblA.get"ext()66 33)

    {

    lblA.set"ext(3 3);

    c#eck();

    private void lbl:Clicked(java.awt.event.ouse/vent evt) {

    00 "-,- add our #andling code #ere+ i$(lbl:.get"ext()66 33)

    {

    lbl:.set"ext(3 -3);

    i$(c#eck:(:)66 :)

    {

    lblr.set"ext(3Rou &in..........3);

    Computer"urn();

  • 7/23/2019 Game tic tac project

    26/43

  • 7/23/2019 Game tic tac project

    27/43

    {

    lblr.set"ext(3Rou &in..........3);

    Computer"urn();

    private void lbl=Clicked(java.awt.event.ouse/vent evt) {

    00 "-,- add our #andling code #ere+

    i$(lbl=.get"ext()66 33)

    {

    lbl=.set"ext(3 -3);

    i$(c#eck:(:)66 :)

    {

    lblr.set"ext(3Rou &in..........3);

    Computer"urn();

    private void lbl>clikced(java.awt.event.ouse/vent evt) {

    00 "-,- add our #andling code #ere+

    i$(lbl>.get"ext()66 33)

    {

    lbl>.set"ext(3 -3);

    i$(c#eck:(:)66 :)

    {

    lblr.set"ext(3Rou &in..........3);

    Computer"urn();

    private void lblAClicked(java.awt.event.ouse/vent evt) {

    00 "-,- add our #andling code #ere+

    i$(lblA.get"ext()66 33)

    {

    lblA.set"ext(3 -3);

    i$(c#eck:(:)66 :)

    { lblr.set"ext(3Rou &in..........3);

    Computer"urn();

    private void lbl@Clicked(java.awt.event.ouse/vent evt) {

    00 "-,- add our #andling code #ere+

  • 7/23/2019 Game tic tac project

    28/43

    i$([email protected]"ext()66 33)

    {

    [email protected]"ext(3 -3);

    i$(c#eck:(:)66 :)

    {

    lblr.set"ext(3Rou &in..........3);

    Computer"urn();

    private void ewClicked(java.awt.event.ouse/vent evt) {

    00 "-,- add our #andling code #ere+

    lbl:.set"ext(33);

    lbl.set"ext(33);

    lbl8.set"ext(33);

    lbl?.set"ext(33);

    lbl.set"ext(33);

    lblA.set"ext(33);

    [email protected]"ext(33);

    lblr.set"ext(33);

    private void jButton:'ctionIer$ormed(java.awt.event.'ction/vent evt) {

    instructions in6new instructions();

    in.s#ow();

    0!!

    ! 1param args t#e command line arguments

    !0

    public static void main(2tring argsST) {

    0! 2et t#e imbus look and $eel !0

    004editor5$old de$aultstate63collapsed3 desc63 9ook and $eel setting code (optional)

    37

    0! *$ imbus (introduced in Java 2/ =) is not available sta wit# t#e de$ault look and

    $eel. ! For details see

    #ttp+00download.oracle.com0javase0tutorial0uiswing0lookand$eel0pla$.#tml

    !0

    tr {

    $or (javax.swing.L*anager.9ook'ndFeel*n$o in$o +

    javax.swing.L*anager.get*nstalled9ook'ndFeels()) {

    i$ (3imbus3.eKuals(in$o.getame())) {

    javax.swing.L*anager.set9ook'ndFeel(in$o.getClassame());

  • 7/23/2019 Game tic tac project

    29/43

    break;

    catc# (ClassotFound/xception ex) {

    java.util.logging.9ogger.get9ogger(GameForm.class.getame()).log(java.util.loggin

    g.9evel.2/N// null ex);

    catc# (*nstantiation/xception ex) {

    java.util.logging.9ogger.get9ogger(GameForm.class.getame()).log(java.util.loggin

    g.9evel.2/N// null ex);

    catc# (*llegal'ccess/xception ex) {

    java.util.logging.9ogger.get9ogger(GameForm.class.getame()).log(java.util.loggin

    g.9evel.2/N// null ex);

    catc# (javax.swing.Lnsupported9ook'ndFeel/xception ex) {

    java.util.logging.9ogger.get9ogger(GameForm.class.getame()).log(java.util.loggin

    g.9evel.2/N// null ex);

    0040editor5$old7

    0! Create and displa t#e $orm !0

    java.awt./ventUueue.invoke9ater(new unnable() {

    public void run() {

    new GameForm().setNisible(true);

    );

    00 Nariables declaration 5 do not modi$

    private javax.swing.JButton btnew;

    private javax.swing.JButton jButton:;

    private javax.swing.J9abel lbl:;

    private javax.swing.J9abel lbl;

    private javax.swing.J9abel lbl8;

    private javax.swing.J9abel lbl?;

    private javax.swing.J9abel lbl;

    private javax.swing.J9abel lblA;

    private javax.swing.J9abel lbl@;

    private javax.swing.J9abel lblr;

    00 /nd o$ variables declaration

  • 7/23/2019 Game tic tac project

    30/43

    package game;

    public class #istor extends javax.swing.JFrame {

    public #istor() {

    initComponents();

    0!!

    ! "#is met#od is called $rom wit#in t#e constructor to initiali%e t#e $orm.

    ! &'*G+ ,o -" modi$ t#is code. "#e content o$ t#is met#od is alwas

    ! regenerated b t#e Form /ditor.

    !0

    12uppress&arnings(3unc#ecked3)

    00 4editor5$old de$aultstate63collapsed3 desc63Generated Code37

    private void initComponents() {

    jButton: 6 new javax.swing.JButton();

    j2crollIane: 6 new javax.swing.J2crollIane();

    j"ext'rea: 6 new javax.swing.J"ext'rea();

    j9abel: 6 new javax.swing.J9abel();

    set,e$aultClose-peration(javax.swing.&indowConstants./*"D-DC9-2/);

    jButton:.setFont(new java.awt.Font(3arrington3 : :A)); 00 -*:A

    jButton:.set"ext(3B'CH3);

    jButton:.add'ction9istener(new java.awt.event.'ction9istener() {

    public void actionIer$ormed(java.awt.event.'ction/vent evt) { jButton:'ctionIer$ormed(evt);

    );

    j"ext'rea:.setColumns(E);

    j"ext'rea:.setFont(new java.awt.Font(3arrington3 : :A)); 00 -*:A

    j"ext'rea:.set9ine&rap(true);

    j"ext'rea:.setows(

  • 7/23/2019 Game tic tac project

    31/43

    :=t# centur. "it b itsel$ means to slap and a W3tit $or tatW3 is retaliation. "oe w#ic# is t#e

    t#ird piece placed makes t#e winning combination b securing t#e ot#er two pieces.

    ecentl tic5tac5toe reac#ed stardom on t#e big screen in t#e ollwood $ilm &argames

    w#ere tic5tac5toe was used to teac# a super5computer about no5win situations.3);

    j2crollIane:.setNiewportNiew(j"ext'rea:);

    j9abel:.setFont(new java.awt.Font(3arrington3 : 8=)); 00 -*:A

    j9abel:.set"ext(3*2"-R3);

    javax.swing.Group9aout laout 6 new javax.swing.Group9aout(getContentIane());

    getContentIane().set9aout(laout);

    laout.setori%ontalGroup(

    laout.createIarallelGroup(javax.swing.Group9aout.'lignment.9/',*G)

    .addGroup(javax.swing.Group9aout.'lignment."'*9*G

    laout.create2eKuentialGroup()

    .addContainerGap(?

  • 7/23/2019 Game tic tac project

    32/43

    00 40editor5$old7

    private void jButton:'ctionIer$ormed(java.awt.event.'ction/vent evt) {

    instructions i6new instructions();

    i.s#ow();

    0!!

    ! 1param args t#e command line arguments

    !0

    public static void main(2tring argsST) {

    0! 2et t#e imbus look and $eel !0

    004editor5$old de$aultstate63collapsed3 desc63 9ook and $eel setting code (optional) 37

    0! *$ imbus (introduced in Java 2/ =) is not available sta wit# t#e de$ault look and

    $eel.

    ! For details see

    #ttp+00download.oracle.com0javase0tutorial0uiswing0lookand$eel0pla$.#tml

    !0 tr {

    $or (javax.swing.L*anager.9ook'ndFeel*n$o in$o +

    javax.swing.L*anager.get*nstalled9ook'ndFeels()) {

    i$ (3imbus3.eKuals(in$o.getame())) {

    javax.swing.L*anager.set9ook'ndFeel(in$o.getClassame());

    break;

    catc# (ClassotFound/xception ex) {

    java.util.logging.9ogger.get9ogger(#istor.class.getame()).log(java.util.logging.9evel.2/N

    // null ex);

    catc# (*nstantiation/xception ex) {

    java.util.logging.9ogger.get9ogger(#istor.class.getame()).log(java.util.logging.9evel.2/N

    // null ex);

    catc# (*llegal'ccess/xception ex) {

    java.util.logging.9ogger.get9ogger(#istor.class.getame()).log(java.util.logging.9evel.2/N

    // null ex);

    catc# (javax.swing.Lnsupported9ook'ndFeel/xception ex) {

    java.util.logging.9ogger.get9ogger(#istor.class.getame()).log(java.util.logging.9evel.2/N

    // null ex);

    0040editor5$old7

    0! Create and displa t#e $orm !0

    java.awt./ventUueue.invoke9ater(new unnable() {

    public void run() {

  • 7/23/2019 Game tic tac project

    33/43

    new #istor().setNisible(true);

    );

    00 Nariables declaration 5 do not modi$

    private javax.swing.JButton jButton:;

    private javax.swing.J9abel j9abel:;

    private javax.swing.J2crollIane j2crollIane:;

    private javax.swing.J"ext'rea j"ext'rea:;

    00 /nd o$ variables declaration

  • 7/23/2019 Game tic tac project

    34/43

    package game;

    import java.sKl.!;

    import java.sKl.Connection;

    import java.sKl.,riveranager;

    import java.sKl.2tatement;

    public class instructions extends javax.swing.JFrame {

    public instructions() {

    initComponents();

    0!!

    ! "#is met#od is called $rom wit#in t#e constructor to initiali%e t#e $orm.

    ! &'*G+ ,o -" modi$ t#is code. "#e content o$ t#is met#od is alwas

    ! regenerated b t#e Form /ditor.

    !0

    12uppress&arnings(3unc#ecked3)

    00 4editor5$old de$aultstate63collapsed3 desc63Generated Code37private void initComponents() {

    jButton: 6 new javax.swing.JButton();

    j"extField: 6 new javax.swing.J"extField();

    j"extField 6 new javax.swing.J"extField();

    j9abel: 6 new javax.swing.J9abel();

    j9abel 6 new javax.swing.J9abel();

    j9abel8 6 new javax.swing.J9abel();

    jButton 6 new javax.swing.JButton();

    jButton8 6 new javax.swing.JButton();

    jButton? 6 new javax.swing.JButton();

    jButton< 6 new javax.swing.JButton(); j9abel? 6 new javax.swing.J9abel();

    j9abel< 6 new javax.swing.J9abel();

    j9abel= 6 new javax.swing.J9abel();

    set,e$aultClose-peration(javax.swing.&indowConstants./*"D-DC9-2/);

    jButton:.setFont(new java.awt.Font(3Comic 2ans 23 : ::)); 00 -*:A

    jButton:.set"ext(3/"/3);

    jButton:.add'ction9istener(new java.awt.event.'ction9istener() {

    public void actionIer$ormed(java.awt.event.'ction/vent evt) {

    jButton:'ctionIer$ormed(evt);

    );

    j"extField:.setFont(new java.awt.Font(3Comic 2ans 23 : ::)); 00 -*:A

    j"extField.setFont(new java.awt.Font(3Comic 2ans 23 : ::)); 00 -*:A

    j9abel:.setFont(new java.awt.Font(3Comic 2ans 23 : ::)); 00 -*:A

  • 7/23/2019 Game tic tac project

    35/43

    j9abel.setFont(new java.awt.Font(3Comic 2ans 23 : ::)); 00 -*:A

    j9abel.set"ext(3'/3);

    j9abel8.setFont(new java.awt.Font(3Comic 2ans 23 : ::)); 00 -*:A

    j9abel8.set"ext(3/5'*93);

    jButton.setFont(new java.awt.Font(3Comic 2ans 23 : ::)); 00 -*:A

    jButton.set"ext(3L9/23);

    jButton.add'ction9istener(new java.awt.event.'ction9istener() {

    public void actionIer$ormed(java.awt.event.'ction/vent evt) {

    jButton'ctionIer$ormed(evt);

    );

    jButton8.setFont(new java.awt.Font(3Comic 2ans 23 : ::)); 00 -*:A

    jButton8.set"ext(3I9'R3);

    jButton8.add'ction9istener(new java.awt.event.'ction9istener() { public void actionIer$ormed(java.awt.event.'ction/vent evt) {

    jButton8'ctionIer$ormed(evt);

    );

    jButton?.setFont(new java.awt.Font(3Comic 2ans 23 : ::)); 00 -*:A

    jButton?.set"ext(3UL*"3);

    jButton?.add'ction9istener(new java.awt.event.'ction9istener() {

    public void actionIer$ormed(java.awt.event.'ction/vent evt) {

    jButton?'ctionIer$ormed(evt);

    );

    jButton

  • 7/23/2019 Game tic tac project

    36/43

  • 7/23/2019 Game tic tac project

    37/43

    .addComponent(j"extField

    javax.swing.Group9aout.I/F//,D2*M/ :

  • 7/23/2019 Game tic tac project

    38/43

    Class.$orame(3sun.jdbc.odbc.Jdbc-dbc,river3);

    Connection connect 6,riveranager.getConnection(3jdbc+odbc+gamedb3);

    2tatement st6connect.create2tatement();

    i$(st.executeLpdate(3*nsert into "able:(SnameTSemailT) values(V3Xj"extField:.get"ext()

    X3VV3Xj"extField.get"ext()X3V)3)66:)

    {

    j9abel:.set"ext(3-& R-L C' I9'RQQQQQQQQQQ3);

    catc#(/xception e)

    {

    j9abel:.set"ext(e.getessage()) ;

    j"extField:.set"ext(33);

    j"extField.set"ext(33);

    private void jButton'ctionIer$ormed(java.awt.event.'ction/vent evt) {

    rules r6new rules();

    r.s#ow();

    private void jButton8'ctionIer$ormed(java.awt.event.'ction/vent evt) {

    GameForm g6new GameForm();

    g.s#ow();

    private void jButton?'ctionIer$ormed(java.awt.event.'ction/vent evt) {

    2stem.exit(E);

    private void jButton

  • 7/23/2019 Game tic tac project

    39/43

    tr {

    $or (javax.swing.L*anager.9ook'ndFeel*n$o in$o +

    javax.swing.L*anager.get*nstalled9ook'ndFeels()) {

    i$ (3imbus3.eKuals(in$o.getame())) {

    javax.swing.L*anager.set9ook'ndFeel(in$o.getClassame());

    break;

    catc# (ClassotFound/xception ex) {

    java.util.logging.9ogger.get9ogger(instructions.class.getame()).log(java.util.logging.9eve

    l.2/N// null ex);

    catc# (*nstantiation/xception ex) {

    java.util.logging.9ogger.get9ogger(instructions.class.getame()).log(java.util.logging.9eve

    l.2/N// null ex);

    catc# (*llegal'ccess/xception ex) {

    java.util.logging.9ogger.get9ogger(instructions.class.getame()).log(java.util.logging.9eve

    l.2/N// null ex);

    catc# (javax.swing.Lnsupported9ook'ndFeel/xception ex) {

    java.util.logging.9ogger.get9ogger(instructions.class.getame()).log(java.util.logging.9eve

    l.2/N// null ex);

    0040editor5$old7

    0! Create and displa t#e $orm !0

    java.awt./ventUueue.invoke9ater(new unnable() { public void run() {

    new instructions().setNisible(true);

    );

    00 Nariables declaration 5 do not modi$

    private javax.swing.JButton jButton:;

    private javax.swing.JButton jButton;

    private javax.swing.JButton jButton8;

    private javax.swing.JButton jButton?;

    private javax.swing.JButton jButton

  • 7/23/2019 Game tic tac project

    40/43

    00 /nd o$ variables declaration

    package game;

    public class rules extends javax.swing.JFrame {

    public rules() {

    initComponents();

    0!!

    ! "#is met#od is called $rom wit#in t#e constructor to initiali%e t#e $orm.

    ! &'*G+ ,o -" modi$ t#is code. "#e content o$ t#is met#od is alwas

    ! regenerated b t#e Form /ditor.

    !0

    12uppress&arnings(3unc#ecked3)

    00 4editor5$old de$aultstate63collapsed3 desc63Generated Code37private void initComponents() {

    j9abel: 6 new javax.swing.J9abel();

    j9abel 6 new javax.swing.J9abel();

    jButton: 6 new javax.swing.JButton();

    j9abel8 6 new javax.swing.J9abel();

    j9abel? 6 new javax.swing.J9abel();

    j9abel< 6 new javax.swing.J9abel();

    j9abel= 6 new javax.swing.J9abel();

    j9abel> 6 new javax.swing.J9abel();

    j9abelA 6 new javax.swing.J9abel();

    set,e$aultClose-peration(javax.swing.&indowConstants./*"D-DC9-2/);

    j9abel:.setFont(new java.awt.Font(3Comic 2ans 23 : ?)); 00 -*:A

    j9abel:.set"ext(3ow to Ila "ic "ac "oe3);

    j9abel.setFont(new java.awt.Font(3Comic 2ans 23 : :A)); 00 -*:A

    j9abel.set"ext(3:. "#e game is plaed on a grid t#atVs 8 sKuares b 8 sKuares.3);

    jButton:.setFont(new java.awt.Font(3Comic 2ans 23 : :A)); 00 -*:A

    jButton:.set"ext(3B'CH3);

    jButton:.add'ction9istener(new java.awt.event.'ction9istener() { public void actionIer$ormed(java.awt.event.'ction/vent evt) {

    jButton:'ctionIer$ormed(evt);

    );

    j9abel8.setFont(new java.awt.Font(3Comic 2ans 23 : :A)); 00 -*:A

    j9abel8.set"ext(3. Rou are our computer in t#is case is -. Ilaers take turns3);

  • 7/23/2019 Game tic tac project

    41/43

    j9abel?.setFont(new java.awt.Font(3Comic 2ans 23 : :A)); 00 -*:A

    j9abel?.set"ext(38. "#e $irst plaer to get 8 marks in a row (up down across or 3);

    j9abel.setFont(new java.awt.Font(3Comic 2ans 23 : :A)); 00 -*:A

    j9abel>.set"ext(3diagonall) is t#e winner.3);

    j9abelA.setFont(new java.awt.Font(3Comic 2ans 23 : :A)); 00 -*:A

    j9abelA.set"ext(3 8 marks in a row t#e game ends in a tie.3);

    javax.swing.Group9aout laout 6 new javax.swing.Group9aout(getContentIane());

    getContentIane().set9aout(laout);

    laout.setori%ontalGroup( laout.createIarallelGroup(javax.swing.Group9aout.'lignment.9/',*G)

    .addGroup(laout.create2eKuentialGroup()

    .addGap(:=> :=> :=>)

    .addComponent(j9abel:)

    .addContainerGap(javax.swing.Group9aout.,/F'L9"D2*M/

    2#ort.'DN'9L/))

    .addGroup(javax.swing.Group9aout.'lignment."'*9*G

    laout.create2eKuentialGroup()

    .addGap(E ?= 2#ort.'DN'9L/)

    .addGroup(laout.createIarallelGroup(javax.swing.Group9aout.'lignment.9/',*G)

    .addComponent(j9abel8)

    .addComponent(j9abel?)

    .addComponent(j9abel > >)

    .addComponent(j9abel>))

    .addGroup(laout.create2eKuentialGroup()

    .addGap(8 8 8)

    .addComponent(j9abelA)) .addComponent(j9abel))

    .addGap(8> 8> 8>))

    .addGroup(javax.swing.Group9aout.'lignment."'*9*G

    laout.create2eKuentialGroup()

    .addContainerGap(javax.swing.Group9aout.,/F'L9"D2*M/ 2#ort.'DN'9L/)

    .addComponent(jButton:)

    .addGap(@? @? @?))

    );

  • 7/23/2019 Game tic tac project

    42/43

    laout.setNerticalGroup(

    laout.createIarallelGroup(javax.swing.Group9aout.'lignment.9/',*G)

    .addGroup(laout.create2eKuentialGroup()

    .addGap(=? =? =?)

    .addComponent(j9abel:)

    .addGap(8@ 8@ 8@)

    .addComponent(j9abel javax.swing.Group9aout.I/F//,D2*M/ :

    javax.swing.Group9aout.I/F//,D2*M/)

    .addGap(:A :A :A)

    .addComponent(j9abel8 javax.swing.Group9aout.I/F//,D2*M/ :

    javax.swing.Group9aout.I/F//,D2*M/)

    .addGap(:A :A :A)

    .addComponent(j9abel=)

    .addGap(:A :A :A)

    .addComponent(j9abel?)

    .addGap(:A :A :A)

    .addComponent(j9abel>)

    .addGap(:A :A :A) .addComponent(j9abel

  • 7/23/2019 Game tic tac project

    43/43

    javax.swing.L*anager.set9ook'ndFeel(in$o.getClassame());

    break;

    catc# (ClassotFound/xception ex) {

    java.util.logging.9ogger.get9ogger(rules.class.getame()).log(java.util.logging.9evel.2/N/

    / null ex);

    catc# (*nstantiation/xception ex) {

    java.util.logging.9ogger.get9ogger(rules.class.getame()).log(java.util.logging.9evel.2/N/

    / null ex);

    catc# (*llegal'ccess/xception ex) {

    java.util.logging.9ogger.get9ogger(rules.class.getame()).log(java.util.logging.9evel.2/N/

    / null ex);

    catc# (javax.swing.Lnsupported9ook'ndFeel/xception ex) {

    java.util.logging.9ogger.get9ogger(rules.class.getame()).log(java.util.logging.9evel.2/N/

    / null ex);

    0040editor5$old7

    0! Create and displa t#e $orm !0

    java.awt./ventUueue.invoke9ater(new unnable() {

    public void run() {

    new rules().setNisible(true);

    );

    00 Nariables declaration 5 do not modi$

    private javax.swing.JButton jButton:;

    private javax.swing.J9abel j9abel:;

    private javax.swing.J9abel j9abel;

    private javax.swing.J9abel j9abel8;

    private javax.swing.J9abel j9abel?;

    private javax.swing.J9abel j9abel;

    private javax.swing.J9abel j9abelA;

    00 /nd o$ variables declaration