Android Open Source - tic-tac-toe Tic Tac Toe






From Project

Back to project page tic-tac-toe.

License

The source code is released under:

Copyright (c) 2009 Florida State University. All rights reserved. Developed by: FSU Android Group Florida State University http://www.cs.fsu.edu Permission is hereby gra...

If you think the Android project tic-tac-toe listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fsu.android.tictactoe;
//from w  ww.  j  av  a  2  s . c  o  m
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class TicTacToe extends Activity {
  
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        /* get controls */
        final Button pvp = (Button) findViewById(R.id.pvp);
        final Button pvc = (Button) findViewById(R.id.pvc);
        final Button vs = (Button) findViewById(R.id.vs);
        final Button quit = (Button) findViewById(R.id.quit);
        
        /* so the listeners can access me */
        final TicTacToe me = this;
        
        /* quit control */
        quit.setOnClickListener(new Button.OnClickListener( ) {
            public void onClick(View v) {
              me.finish( );
            }
        });
        
        /* player versus player control */
        pvp.setOnClickListener(new Button.OnClickListener( ) {
            public void onClick(View v) {
              Intent i = new Intent(me, Game.class);
              i.setType("2");
              me.startActivity(i);
            }
        });
        
        /* player versus computer control */
        pvc.setOnClickListener(new Button.OnClickListener( ) {
            public void onClick(View v) {
              Intent i = new Intent(me, Game.class);
              i.setType("1");
              me.startActivity(i);
            }
        });
        
        /* view high score control */
        vs.setOnClickListener(new Button.OnClickListener( ) {
            public void onClick(View v) {
              Intent i = new Intent(me, StatsView.class);
              i.setType("1");
              me.startActivity(i);
            }
        });
    }
}




Java Source Code List

fsu.android.tictactoe.Game.java
fsu.android.tictactoe.NameDialog.java
fsu.android.tictactoe.StatsDatabase.java
fsu.android.tictactoe.StatsView.java
fsu.android.tictactoe.TicTacToe.java