Tampilkan postingan dengan label Source Code. Tampilkan semua postingan
Tampilkan postingan dengan label Source Code. Tampilkan semua postingan

Sabtu, 30 Maret 2013

Sekian lama kosong, setidaknya saya ingin membuat sebuah postingan dalam bulan maret ini. Kali ini berhubungan dengan php, dan materi kali ini masih sangat dasar. Maksud dari judul saya diatas adalah menampilkan kembali sebuah tulisan yang sebelumnya telah kita masukkan, terus ketika mensubmit tulisan tersebut, maka tulisan yang kita submit tadi langsung tampil di monitor. dan ingat, ini berbeda dengan menampilkan isi tabel hasil inputan dengan PHP yang Insya Allah akan segera saya bikin postingannya. 
http://go-program.blogspot.com/2013/03/cara-menampilkan-hasil-inputan-dengan-php.html

Jadi karena hanya menampilkan kembali hasil inputan, kita belum membutuhkan database, kita hanya menggunakan perpaduan antara HTML dengan PHP. Agan-agan sekalian dapat mencobanya pada localhost masing-masing ya. Agar lebih mengerti manfaatnya kita ambil contoh untuk menampilkan kembali hasil pengisian form saja dulu ya. Langsung saja saya tampilkan tutorialnya:

  1. Langkah pertama kita buat sebuah form dari html agar kita dapat menginputkan tulisan dan mensubmit tulisan tersebut. Copy paste/tulis kembali form HTML dibawah ini lalu simpan dengan nama index.html. Agan bisa memodifikasi struktur html dibawah sesuka hati agan.
    <!DOCTYPE html>

    <head>
    <title>Belajar membuat form</title>
    </head>

    <body style='background:url(http://cs.unsyiah.ac.id/~alamri/gambar/001.png);'>
    <div style="background:#D4D4D4;width:600px; margin:50px auto 0px auto;padding:10px;border-radius:4px;">
    <h2 style='background:#212121;color:#f2f2f2;padding:10px;margin:-10px -10px 0px -10px;text-align:center'>Form Pengisian biodata</h2>
    <fieldset>
    <legend style="font-family:arial;">Identitas diri</legend>
    <form action="tampil.php">
    <table>
    <tr><td>NIM</td><td>:</td><td><input type="text" name="nim"/></td></tr>
    <tr><td>Nama</td><td>:</td><td><input type="text" name="nama"/></td></tr>
    <tr><td>Jenis Kelamin</td><td>:</td><td><input type="radio" name="kelamin" value="laki-laki">Pria</td><td><input type="radio" name="kelamin" value="Perempuan">Wanita</td>
    <tr><td>Jurusan</td><td>:</td><td><input type="text" name="jurusan"/></td></tr>
    <tr><td>IPK</td><td>:</td><td><input type="text" name="ipk"/></td></tr>
    <tr><td><input type="submit" value="kirim"/></td><td><input type="reset" value="batalkan"/></tr>
    </table>
    </form>
    </fieldset>
    </div>
    </body>

    </html>
  2. Langkah kedua yaitu membuat sebuah file berformat php untuk menampilkan apa yang baru saja agan input. Agan Copy paste/tulis kembali form php dibawah ini lalu simpan dengan nama tampil.php. 
    <?php 
    $nim=$_GET['nim'];
    $nama=$_GET['nama'];
    $jurusan=$_GET['jurusan'];
    $ipk=$_GET['ipk'];
    $kelamin=$_GET['kelamin'];

    echo "<h1 align='center' style='text-align:center'>Data Diri Anda</h1></br></br>
    <body style='background:#939393 url(http://cs.unsyiah.ac.id/~alamri/gambar/001.png)'>
    <div style='background:#f2f2f2;width:600px; margin:0 auto'>
    <fieldset>
    <legend style='font-family:arial;'>Identitas diri</legend>
    <table>
    <tr><td>NIM</td><td>:</td><td>$nim</td></tr>
    <tr><td>Nama</td><td>:</td><td>$nama</td></tr>
    <tr><td>Kelamin</td><td>:</td><td>$kelamin</td></tr>
    <tr><td>Jurusan</td><td>:</td><td>$jurusan</td></tr>
    <tr><td>IPK</td><td>:</td><td>$ipk</td></tr>
    </table>
    </fieldset>
    </div>
    </body>";

    ?>
Nah, disini hanya memerlukan 2 file saja. Untuk melihat contoh hasil jadinya, anda dapat melihatnya langsung disini: http://cs.unsyiah.ac.id/~alamri/pbw/tugas1/ .

Sekarang coba lihat pada file index.html, ada bagian <form action="tampil.php">, nah disitu maksudnya adalah melakukan sebuah aksi untuk menuju atau mengirimkan apapun ke halaman tampil.php ketika kita mengklik (mensubmit nya). Jadi pada halaman index.html pada setiap elemen yang akan diisi kita buat name="" masing-masing. Itulah tanda yang akan dikirim ke tampil.php, Pada file tampil.php dibuat beberapa variabel sesuai dengan name="" yang dikirim dari index.html. Kira-kira begitulah penjelasan ringkasnya. Jika ada yang kurang dipahami silahkan kirim email atau beri komentar saja ya.. :)

Kamis, 31 Januari 2013

berikut ini salah satu tugas yang lumayan sangat gamapang dari tugas-tugas pemrograman lainnya. permasalahan disini yaitu mencari sebuah angka yang diinput user dari sejumlah data yang telah dirandom kemudian diurutkan menggunakan quicksort. Jadi bisa dikatakan ini gabungan dari quick sort dengan binary search. Kira kira berikut ini penampakan hasil yang diinginkan.

http://go-program.blogspot.com/2013/01/implementasi-quick-sort-dengan-binary-di-c.html


Tugas ini saya katakan sangat mudah karena source code yang diperlukan sudah ada semuanya, namun sebenarnya akan susah jika dipahami source code baris-perbarisnya. apalagi adanya fungsi rekusif dalam quicksort dan binary search Lumayan memusingkan. Berikut ini source code implementasi dari quick sort dengan binary search seperti gambar diatas.

/*--------------------------------------------------------------------*/
/*-------------Nama : Ahmad Ariful Amri ----------------------------*/
/*-------------Program: Quick sort dan implementasi Binary Search-----*/
/*--------------------------------------------------------------------*/

#include <stdio.h>
#include <time.h>
#include <stdlib.h>

/*Prototype dari metode sorting quick sort*/
void quickSort( int[], int, int);
int partition( int[], int, int);

int main()
{
int data[100000], i, n, menu, item, mid, top, bottom;
time_t start, stop;//sebagai penghitung waktu
printf("Masukkan Jumlah Bilangan (n): ");
scanf("%d", &n);

for (i = 0; i < n; i++)
{
data[i]=rand() % n + 1;
}
printf("Random data dalam array selesain");

time(&start);//Mulai menghitung waktu
quickSort( data, 0, n);
//Untuk menampilkan data yang telah diurutkan (Jika diperlukan)
//printf("Data setelah diurutkan dengan QUICK SORT :n");
//for(i = 0; i < n; ++i)
//{
// printf("%dt", data[i]);
//}
time(&stop);//Berhenti menghitung waktu
printf("Data sudah diurutkan menggunakan metode QUICK SORT :n");
printf("nnWaktu yang dibutuhkan untuk mengurutkan: %.0f detik. nnn", difftime(stop, start));/*Menampilkan total waktu yang dibutuhkan*/

do
{
printf("|==============================================================|n");
printf("|---Mencari data yang telah diurutkan menggunakan Quick Sort---|n");
printf("|==============================================================|n");
printf("|Pilihan: |n");
printf("|1) Mencari data dengan BINARY SEARCH dan menampilkan hasilnya |n");
printf("|2) Random ulang data dalam array |n");
printf("|3) Selesai (EXIT) |n");
printf("|--------------------------------------------------------------|n");
printf("|Pilihan anda: ");
scanf("%d", &menu);
printf("nn");
switch(menu)
{
/***************************INSERTION SORT*************************/
case 1:
printf("Masukkan data yang ingin dicari :");
scanf("%d",&item);
bottom = 1;
top = n;

do
{
mid = (bottom + top) / 2;
if (item < data[mid])
{
top = mid - 1;
}
else if (item > data[mid])
{
bottom = mid + 1;
}
}
while (item != data[mid] && bottom <= top);

if (item == data[mid])
{
printf("nNilai %d Ditemukan pada indeks ke: %dnnn", item, mid + 1);
}
else
{
printf("nPencarian gagal, %d Tidak ditemukannn", item);
}
break;
/********************************Akhir dari Binary Search ***********************/
case 2:
printf("Masukkan jumlah bilangan (n) :");
scanf("%d", &n);
/*Memasukkan jumlah data(bilangan) kemudian akan dirandom*/
for(i=0; i<n; i++)
{
data[i]=rand() % n + 1; //merandom data dari 1 - n dan disimpan ke array
}
printf("Random data dalam array selesainn");

time(&start);//Mulai menghitung waktu
quickSort( data, 0, n);
//Untuk menampilkan data yang telah diurutkan (Jika diperlukan)
//printf("Data setelah diurutkan dengan QUICK SORT :n");
//for(i = 0; i < n; ++i)
//{
// printf("%dt", data[i]);
//}
time(&stop);//Berhenti menghitung waktu
printf("Data sudah diurutkan menggunakan metode QUICK SORT :n");
printf("nnWaktu yang dibutuhkan untuk mengurutkan: %.0f detik. nnn", difftime(stop, start));/*Menampilkan total waktu yang dibutuhkan*/

break;
case 3:break;
}
/*Jika memasukkan menu yang tidak sesuai dengan pilihan*/
if(menu!=1 && menu!=2 && menu!=3)
{
printf("Maaf..Anda Salah Memasukkan Pilihan!!!nPilihan anda nomor %d TIDAK ada pada menu", menu);
printf("nSilahkan pilih menu dibawah dari 1 - 3, Terima Kasih :)nn");
}
}while(menu != 3);

return EXIT_SUCCESS;
}

void quickSort( int data[], int l, int r)
{
int j;
if( l < r )
{
// divide and conquer
j = partition( data, l, r);
quickSort( data, l, j-1);
quickSort( data, j+1, r);
}
}

/*Pembagian partisi*/
int partition( int data[], int l, int r)
{
int pivot, i, j, t;
pivot = data[l];
i = l; j = r+1;

while( 1)
{
do ++i; while( data[i] <= pivot && i <= r );
do --j; while( data[j] > pivot );
if( i >= j ) break;
t = data[i]; data[i] = data[j]; data[j] = t;
}
t = data[l]; data[l] = data[j]; data[j] = t;
return j;
}

Agar lebih mudah untuk di trace. silahkan copas source code diatas ke notepad++ atau pengolah kata kesayangan anda lainnya.

Jumat, 25 Januari 2013

program.blogspot.com/2013/01/program-sederhana-c-konversi-detik-ke.html
berhubung sedang kurang bergairah dalam dunia pemrograma, jadi malam ini sharing-sharing hal yang sederhana aja yaw. Kali ini akan saya posting contoh program sederhana untuk mengkonversi detik dari masukan user ke dalam satuan jam dan menit. Kalau dibayangin sepertinya mudah. inilah source code nya :)

/*----------------------------------------------------------------*/
/*-------------Nama : Ahmad Ariful Amri ------------------------*/
/*-------------Program: Konversi detik ke menit dan jam-----------*/
/*-----------------visit: go-program.blogspot.com-----------------*/
/*----------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>

int main()
{
int jam, menit, detik, sisa;
printf("Jumlah detik yang diinginkan : ");
scanf("%d", &detik);
jam = detik/3600;
sisa = detik%3600;
menit = sisa / 60;
detik = sisa % 60;

printf("setara dengan %d jam %d menit %d detikn",jam,menit,detik);

return EXIT_SUCCESS;
}

Gampang sekali kan? semoga bisabermanfaat ya...

Rabu, 09 Januari 2013

Tepat Pada Postingan Sebelumnya saya membahas tentang Algoritma metode pengurutan menggunakan Metode Insertion Sort. Nah disini akan diberikan contoh program untuk mengurutkan sekumpulan data yang telah dirandom menggunakan fungsi Rand() (KLIK), contoh yang saya berikan disini menggunakan bahasa C
insertion sort http://go-program.blogspot.com/2013/01/pengurutan-data-random-dengan-insertion-sort-di-c.html

/*------------------------------------------------------------------*/
/*-----------Nama : Ahmad Ariful Amri ----------------------------*/
/*-----------Program: Pengurutan data random dengan insertion sort--*/
/*---------------------------www.go-program.blogspot.com------------*/
/*------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>

int main()
{
int n, data[1000], i, j, t;

printf("Masukkan Jumlah data : ");
scanf("%d", &n);

for (i = 0; i < n; i++)
{
data[i]=rand() % 100000 + 1;
}

for (i = 1 ; i <= n - 1; i++) {
j = i;

while ( j > 0 && data[j] < data[j-1]) {
t = data[j];
data[j] = data[j-1];
data[j-1] = t;

j--;
}
}

printf("Data setelah diurutkan:n");

for (i = 0; i <= n - 1; i++) {
printf("%dt", data[i]);
}

return 0;
}

Konsep dari program diatas, pengguna akan diminta memasukkan jumlah data yang ingin dirandom sebanyak n buah bilangan. Kebetulan ceritanya diatas saya memasukan nilai 27, yang berarti akan dirandom data sebanyak 27 angka dari angka 1 - dengan n. setelah dirandom, data/angka tersebut disimpan dalam sebuah array. pada contoh diatas, bilangan yang sudah dirandom disimpan pada array data[i]. Selanjutnya angka.bilangan yang terdapat dalam itulah yang di urutkan menggunakan meode insertion sort.

Minggu, 06 Januari 2013

Sebenarnya saya lagi bingung mau posting apa, jadi daripada lama tidak update, saya posting saja contoh-contoh kecil yang siapa tau dibalik pendugaan ketidak gunaannya ini, rupanya inilah yang paling banyak dicari orang-orang, namun tidak ada yang posting sebelumnya. ohohoh.. memang beginilah lah terbawa khayalan harapan. 

berikut ini contoh sederhana penggunaan method equals yang iseng iseng saya buat ketika belajar soal UAS.

import java.util.*;
class CobaEquals
{
public static void main(String args [])
{
String jurusan;
Scanner in = new Scanner(System.in);

System.out.print("kamu Mahasiswa Jurusan Apa? ");
jurusan =in.nextLine();

System.out.println(jurusan);

if(jurusan.equals("Informatika") || jurusan.equals("informatika"))
{
System.out.println("nnSelamat datang masbro");
}
else
{
System.out.println("nnMaaf, ini hanya untuk Jurusan Informatika, silahkan ikut SNMPTN Ulang :p");
}
}
}

Ntar kalau dijalanakan penampakannya akan seperti ini:
http://go-program.blogspot.com/2013/01/contoh-penggunaan-method-equals-di-java.html
Begitulah kira kira contoh sederhananya, masih banyak contoh untuk penggunaan lainnya, silahkan berkreasi sendiri yaa 

Jumat, 04 Januari 2013

http://go-program.blogspot.com/2013/01/source-code-tugas-java-applet-2-game.html
Sesuai janji, kali ini saya akan posting source code yang saya kumpulkan sebagai tugas 2 mata kuliah PBO (Pemrograman Beriorentasi Objek)(Kami menggunakan Java). Tugas 2 yang diberikan yaitu membuat sebuah game Applet tictactoe tanpa AI(Artificial Inteligent) dan tanpa aturan menang, sehingga hanya untuk diklik-klik saja. Namun bagi mereka yang membuat sistem aturan menang yang apabila posisinya berjajar 5 kali secara berturut-turut maka akan menang. Sebelumnya saya sudah posting source code yang dimiliki dosen. (baca: Source Code Java Applet 1 Game TicTacToe)

Mungkin tugas ini tidak terlalu sulit, karena selain sudah berhasil mendapatkan source code punya robot si dosen, saya juga berhasil mendapatkan berbagai contoh java applet tictactoe dari hasil googling, ada lumayan banyak sampai belasan gitu. Jadi saya hanya tinggal memilih dan sedikit melakukan modifikasi. adapun hasil akhir yang saya kumpulkan yaitu:

/*--------------------------------------------------------*/
/*-----Author : Ahmad Ariful Amri-----------------------*/
/*-----Program : Applet Tictactoe------------------------*/
/*------------http://go-program.blogspot.com--------------*/
/*--------------------------------------------------------*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.LineBorder;

public class TicTacToe extends JApplet
{
private char whoseTurn = 'X';
private Cell[][] cells = new Cell[10][10];
private JLabel jlblStatus = new JLabel("Giliran Pemain X");

public TicTacToe()
{
GridLayout grid = new GridLayout(10, 10, 0, 0);
JPanel p = new JPanel(grid);
for (int i = 0; i < 10; i++)
for (int j = 0; j < 10; j++)
p.add(cells[i][j] = new Cell());

p.setBorder(new LineBorder(Color.black, 1));
jlblStatus.setBorder(new LineBorder(Color.gray, 1));

add(p, BorderLayout.CENTER);
add(jlblStatus, BorderLayout.SOUTH);
}

public boolean isFull()
{
for (int i = 0; i < 10; i++)
for (int j = 0; j < 10; j++)
if (cells[i][j].getToken() == ' ')
return false;

return true;
}

public boolean isWon(char token) //Penentuan aturan menang
{ /*-----------------------------------------------------------------------------------------------------Kondisi Menang Horizontal--------------------------------------------------------------------------------------------------------------------------*/
for (int i = 0; i < 10; i++)
{
if ((cells[i][0].getToken() == token) && (cells[i][1].getToken() == token) && (cells[i][2].getToken() == token) && (cells[i][3].getToken() == token) && (cells[i][4].getToken() == token)) { return true;} /*Horizontal dari baris 1 sampai baris 5*/
else if((cells[i][1].getToken() == token) && (cells[i][2].getToken() == token) && (cells[i][3].getToken() == token) && (cells[i][4].getToken() == token) && (cells[i][5].getToken() == token)){return true;} /*Horizontal dari baris 2 sampai baris 6*/
else if((cells[i][2].getToken() == token) && (cells[i][3].getToken() == token) && (cells[i][4].getToken() == token) && (cells[i][5].getToken() == token) && (cells[i][6].getToken() == token)){return true;} /*Horizontal dari baris 3 sampai baris 7*/
else if((cells[i][3].getToken() == token) && (cells[i][4].getToken() == token) && (cells[i][5].getToken() == token) && (cells[i][6].getToken() == token) && (cells[i][7].getToken() == token)){return true;} /*Horizontal dari baris 4 sampai baris 8*/
else if((cells[i][4].getToken() == token) && (cells[i][5].getToken() == token) && (cells[i][6].getToken() == token) && (cells[i][7].getToken() == token) && (cells[i][8].getToken() == token)){return true;} /*Horizontal dari baris 5 sampai baris 9*/
else if((cells[i][5].getToken() == token) && (cells[i][6].getToken() == token) && (cells[i][7].getToken() == token) && (cells[i][8].getToken() == token) && (cells[i][9].getToken() == token)){return true;} /*Horizontal dari baris 6 sampai baris 10*/
}
/*-----------------------------------------------------------------------------------------------------Kondisi Menang Vertikal----------------------------------------------------------------------------------------------------------------------------*/
for (int j = 0; j < 10; j++)
{
if ((cells[0][j].getToken() == token) && (cells[1][j].getToken() == token) && (cells[2][j].getToken() == token) && (cells[3][j].getToken() == token) && (cells[4][j].getToken() == token)) {return true;} /*Vertikal dari kolom 1 sampai kolom 5*/
else if ((cells[1][j].getToken() == token) && (cells[2][j].getToken() == token) && (cells[3][j].getToken() == token) && (cells[4][j].getToken() == token) && (cells[5][j].getToken() == token)){return true;} /*vertikal dari kolom 2 sampai kolom 6*/
else if ((cells[2][j].getToken() == token) && (cells[3][j].getToken() == token) && (cells[4][j].getToken() == token) && (cells[5][j].getToken() == token) && (cells[6][j].getToken() == token)){return true;} /*vertikal dari kolom 3 sampai kolom 7*/
else if ((cells[3][j].getToken() == token) && (cells[4][j].getToken() == token) && (cells[5][j].getToken() == token) && (cells[6][j].getToken() == token) && (cells[7][j].getToken() == token)){return true;} /*vertikal dari kolom 4 sampai kolom 8*/
else if ((cells[4][j].getToken() == token) && (cells[5][j].getToken() == token) && (cells[6][j].getToken() == token) && (cells[7][j].getToken() == token) && (cells[8][j].getToken() == token)){return true;} /*vertikal dari kolom 5 sampai kolom 9*/
else if ((cells[5][j].getToken() == token) && (cells[6][j].getToken() == token) && (cells[7][j].getToken() == token) && (cells[8][j].getToken() == token) && (cells[9][j].getToken() == token)){return true;} /*vertikal dari kolom 6 sampai kolom 10*/
}

/*------------------------------------------------------------------------------------------------------Kondisi Menang Kiri atas ke Kanan Bawah-----------------------------------------------------------------------------------------------------------*/
if ((cells[0][0].getToken() == token) && (cells[1][1].getToken() == token) && (cells[2][2].getToken() == token) && (cells[3][3].getToken() == token) && (cells[4][4].getToken() == token)) {return true;} /*serong dari kiri atas ke kanan bawah dari kolom 1 sampai kolom 5*/
else if((cells[1][1].getToken() == token) && (cells[2][2].getToken() == token) && (cells[3][3].getToken() == token) && (cells[4][4].getToken() == token) && (cells[5][5].getToken() == token)){return true;} /*serong dari kiri atas ke kanan bawah dari kolom 2 sampai kolom 6*/
else if((cells[2][2].getToken() == token) && (cells[3][3].getToken() == token) && (cells[4][4].getToken() == token) && (cells[5][5].getToken() == token) && (cells[6][6].getToken() == token)){return true;} /*serong dari kiri atas ke kanan bawah dari kolom 3 sampai kolom 7*/
else if((cells[3][3].getToken() == token) && (cells[4][4].getToken() == token) && (cells[5][5].getToken() == token) && (cells[6][6].getToken() == token) && (cells[7][7].getToken() == token)){return true;} /*serong dari kiri atas ke kanan bawah dari kolom 4 sampai kolom 8*/
else if((cells[4][4].getToken() == token) && (cells[5][5].getToken() == token) && (cells[6][6].getToken() == token) && (cells[7][7].getToken() == token) && (cells[8][8].getToken() == token)){return true;} /*serong dari kiri atas ke kanan bawah dari kolom 5 sampai kolom 9*/
else if((cells[5][5].getToken() == token) && (cells[6][6].getToken() == token) && (cells[7][7].getToken() == token) && (cells[8][8].getToken() == token) && (cells[9][9].getToken() == token)){return true;} /*serong dari kiri atas ke kanan bawah dari kolom 6 sampai kolom 10*/

if ((cells[0][0].getToken() == token) && (cells[1][1].getToken() == token) && (cells[2][2].getToken() == token) && (cells[3][3].getToken() == token) && (cells[4][4].getToken() == token)) {return true;} /*00 - 44*/
else if ((cells[0][1].getToken() == token) && (cells[1][2].getToken() == token) && (cells[2][3].getToken() == token) && (cells[3][4].getToken() == token) && (cells[4][5].getToken() == token)) {return true;} /*01 - 45*/
else if ((cells[0][2].getToken() == token) && (cells[1][3].getToken() == token) && (cells[2][4].getToken() == token) && (cells[3][5].getToken() == token) && (cells[4][6].getToken() == token)) {return true;} /*02 - 46*/
else if ((cells[0][3].getToken() == token) && (cells[1][4].getToken() == token) && (cells[2][5].getToken() == token) && (cells[3][6].getToken() == token) && (cells[4][7].getToken() == token)) {return true;} /*03 - 47*/
else if ((cells[0][4].getToken() == token) && (cells[1][5].getToken() == token) && (cells[2][6].getToken() == token) && (cells[3][7].getToken() == token) && (cells[4][8].getToken() == token)) {return true;} /*04 - 48*/
else if ((cells[0][5].getToken() == token) && (cells[1][6].getToken() == token) && (cells[2][7].getToken() == token) && (cells[3][8].getToken() == token) && (cells[4][9].getToken() == token)) {return true;} /*05 - 49*/

else if ((cells[1][0].getToken() == token) && (cells[2][1].getToken() == token) && (cells[3][2].getToken() == token) && (cells[4][3].getToken() == token) && (cells[5][4].getToken() == token)) {return true;} /*10 - 54*/
else if ((cells[1][1].getToken() == token) && (cells[2][2].getToken() == token) && (cells[3][3].getToken() == token) && (cells[4][4].getToken() == token) && (cells[5][5].getToken() == token)) {return true;} /*11 - 55*/
else if ((cells[1][2].getToken() == token) && (cells[2][3].getToken() == token) && (cells[3][4].getToken() == token) && (cells[4][5].getToken() == token) && (cells[5][6].getToken() == token)) {return true;} /*12 - 56*/
else if ((cells[1][3].getToken() == token) && (cells[2][4].getToken() == token) && (cells[3][5].getToken() == token) && (cells[4][6].getToken() == token) && (cells[5][7].getToken() == token)) {return true;} /*13 - 57*/
else if ((cells[1][4].getToken() == token) && (cells[2][5].getToken() == token) && (cells[3][6].getToken() == token) && (cells[4][7].getToken() == token) && (cells[5][8].getToken() == token)) {return true;} /*14 - 58*/
else if ((cells[1][5].getToken() == token) && (cells[2][6].getToken() == token) && (cells[3][7].getToken() == token) && (cells[4][8].getToken() == token) && (cells[5][9].getToken() == token)) {return true;} /*15 - 59*/

else if ((cells[2][0].getToken() == token) && (cells[3][1].getToken() == token) && (cells[4][2].getToken() == token) && (cells[5][3].getToken() == token) && (cells[6][4].getToken() == token)) {return true;} /*20 - 64*/
else if ((cells[2][1].getToken() == token) && (cells[3][2].getToken() == token) && (cells[4][3].getToken() == token) && (cells[5][4].getToken() == token) && (cells[6][5].getToken() == token)) {return true;} /*21 - 65*/
else if ((cells[2][2].getToken() == token) && (cells[3][3].getToken() == token) && (cells[4][4].getToken() == token) && (cells[5][5].getToken() == token) && (cells[6][6].getToken() == token)) {return true;} /*22 - 66*/
else if ((cells[2][3].getToken() == token) && (cells[3][4].getToken() == token) && (cells[4][5].getToken() == token) && (cells[5][6].getToken() == token) && (cells[6][7].getToken() == token)) {return true;} /*23 - 67*/
else if ((cells[2][4].getToken() == token) && (cells[3][5].getToken() == token) && (cells[4][6].getToken() == token) && (cells[5][7].getToken() == token) && (cells[6][8].getToken() == token)) {return true;} /*24 - 68*/
else if ((cells[2][5].getToken() == token) && (cells[3][6].getToken() == token) && (cells[4][7].getToken() == token) && (cells[5][8].getToken() == token) && (cells[6][9].getToken() == token)) {return true;} /*25 - 69*/

else if ((cells[3][0].getToken() == token) && (cells[4][1].getToken() == token) && (cells[5][2].getToken() == token) && (cells[6][3].getToken() == token) && (cells[7][4].getToken() == token)) {return true;} /*30 - 74*/
else if ((cells[3][1].getToken() == token) && (cells[4][2].getToken() == token) && (cells[5][3].getToken() == token) && (cells[6][4].getToken() == token) && (cells[7][5].getToken() == token)) {return true;} /*31 - 75*/
else if ((cells[3][2].getToken() == token) && (cells[4][3].getToken() == token) && (cells[5][4].getToken() == token) && (cells[6][5].getToken() == token) && (cells[7][6].getToken() == token)) {return true;} /*32 - 76*/
else if ((cells[3][3].getToken() == token) && (cells[4][4].getToken() == token) && (cells[5][5].getToken() == token) && (cells[6][6].getToken() == token) && (cells[7][7].getToken() == token)) {return true;} /*33 - 77*/
else if ((cells[3][4].getToken() == token) && (cells[4][5].getToken() == token) && (cells[5][6].getToken() == token) && (cells[6][7].getToken() == token) && (cells[7][8].getToken() == token)) {return true;} /*34 - 78*/
else if ((cells[3][5].getToken() == token) && (cells[4][6].getToken() == token) && (cells[5][7].getToken() == token) && (cells[6][8].getToken() == token) && (cells[7][9].getToken() == token)) {return true;} /*35 - 79*/

else if ((cells[4][0].getToken() == token) && (cells[5][1].getToken() == token) && (cells[6][2].getToken() == token) && (cells[7][3].getToken() == token) && (cells[8][4].getToken() == token)) {return true;} /*40 - 84*/
else if ((cells[4][1].getToken() == token) && (cells[5][2].getToken() == token) && (cells[6][3].getToken() == token) && (cells[7][4].getToken() == token) && (cells[8][5].getToken() == token)) {return true;} /*41 - 85*/
else if ((cells[4][2].getToken() == token) && (cells[5][3].getToken() == token) && (cells[6][4].getToken() == token) && (cells[7][5].getToken() == token) && (cells[8][6].getToken() == token)) {return true;} /*42 - 86*/
else if ((cells[4][3].getToken() == token) && (cells[5][4].getToken() == token) && (cells[6][5].getToken() == token) && (cells[7][6].getToken() == token) && (cells[8][7].getToken() == token)) {return true;} /*43 - 87*/
else if ((cells[4][4].getToken() == token) && (cells[5][5].getToken() == token) && (cells[6][6].getToken() == token) && (cells[7][7].getToken() == token) && (cells[8][8].getToken() == token)) {return true;} /*44 - 88*/
else if ((cells[4][5].getToken() == token) && (cells[5][6].getToken() == token) && (cells[6][7].getToken() == token) && (cells[7][8].getToken() == token) && (cells[8][9].getToken() == token)) {return true;} /*45 - 89*/

else if ((cells[5][0].getToken() == token) && (cells[6][1].getToken() == token) && (cells[7][2].getToken() == token) && (cells[8][3].getToken() == token) && (cells[9][4].getToken() == token)) {return true;} /*50 - 94*/
else if ((cells[5][1].getToken() == token) && (cells[6][2].getToken() == token) && (cells[7][3].getToken() == token) && (cells[8][4].getToken() == token) && (cells[9][5].getToken() == token)) {return true;} /*51 - 95*/
else if ((cells[5][2].getToken() == token) && (cells[6][3].getToken() == token) && (cells[7][4].getToken() == token) && (cells[8][5].getToken() == token) && (cells[9][6].getToken() == token)) {return true;} /*52 - 96*/
else if ((cells[5][3].getToken() == token) && (cells[6][4].getToken() == token) && (cells[7][5].getToken() == token) && (cells[8][6].getToken() == token) && (cells[9][7].getToken() == token)) {return true;} /*53 - 97*/
else if ((cells[5][4].getToken() == token) && (cells[6][5].getToken() == token) && (cells[7][6].getToken() == token) && (cells[8][7].getToken() == token) && (cells[9][8].getToken() == token)) {return true;} /*54 - 98*/
else if ((cells[5][5].getToken() == token) && (cells[6][6].getToken() == token) && (cells[7][7].getToken() == token) && (cells[8][8].getToken() == token) && (cells[9][9].getToken() == token)) {return true;} /*55 - 99*/

/*------------------------------------------------------------------------------------------------------Kondisi Menang Kiri bawah ke Kanan atas-----------------------------------------------------------------------------------------------------------*/
if ((cells[0][4].getToken() == token) && (cells[1][3].getToken() == token) && (cells[2][2].getToken() == token) && (cells[3][1].getToken() == token) && (cells[4][0].getToken() == token)) { return true;} /*04 - 40*/
else if ((cells[0][5].getToken() == token) && (cells[1][4].getToken() == token) && (cells[2][3].getToken() == token) && (cells[3][2].getToken() == token) && (cells[4][1].getToken() == token)) {return true;} /*05 - 41*/
else if ((cells[0][6].getToken() == token) && (cells[1][5].getToken() == token) && (cells[2][4].getToken() == token) && (cells[3][3].getToken() == token) && (cells[4][2].getToken() == token)) {return true;} /*06 - 42*/
else if ((cells[0][7].getToken() == token) && (cells[1][6].getToken() == token) && (cells[2][5].getToken() == token) && (cells[3][4].getToken() == token) && (cells[4][3].getToken() == token)) {return true;} /*07 - 43*/
else if ((cells[0][8].getToken() == token) && (cells[1][7].getToken() == token) && (cells[2][6].getToken() == token) && (cells[3][5].getToken() == token) && (cells[4][4].getToken() == token)) {return true;} /*08 - 44*/
else if ((cells[0][9].getToken() == token) && (cells[1][8].getToken() == token) && (cells[2][7].getToken() == token) && (cells[3][6].getToken() == token) && (cells[4][5].getToken() == token)) {return true;} /*09 - 45*/

else if ((cells[1][4].getToken() == token) && (cells[2][3].getToken() == token) && (cells[3][2].getToken() == token) && (cells[4][1].getToken() == token) && (cells[5][0].getToken() == token)) {return true;} /*19 - 55*/
else if ((cells[1][5].getToken() == token) && (cells[2][4].getToken() == token) && (cells[3][3].getToken() == token) && (cells[4][2].getToken() == token) && (cells[5][1].getToken() == token)) {return true;} /*15 - 51*/
else if ((cells[1][6].getToken() == token) && (cells[2][5].getToken() == token) && (cells[3][4].getToken() == token) && (cells[4][3].getToken() == token) && (cells[5][2].getToken() == token)) {return true;} /*16 - 52*/
else if ((cells[1][7].getToken() == token) && (cells[2][6].getToken() == token) && (cells[3][5].getToken() == token) && (cells[4][4].getToken() == token) && (cells[5][3].getToken() == token)) {return true;} /*17 - 53*/
else if ((cells[1][8].getToken() == token) && (cells[2][7].getToken() == token) && (cells[3][6].getToken() == token) && (cells[4][5].getToken() == token) && (cells[5][4].getToken() == token)) {return true;} /*18 - 54*/
else if ((cells[1][9].getToken() == token) && (cells[2][8].getToken() == token) && (cells[3][7].getToken() == token) && (cells[4][6].getToken() == token) && (cells[5][5].getToken() == token)) {return true;} /*19 - 55*/

else if ((cells[2][4].getToken() == token) && (cells[3][3].getToken() == token) && (cells[4][2].getToken() == token) && (cells[5][1].getToken() == token) && (cells[6][0].getToken() == token)) {return true;} /*29 - 65*/
else if ((cells[2][5].getToken() == token) && (cells[3][4].getToken() == token) && (cells[4][3].getToken() == token) && (cells[5][2].getToken() == token) && (cells[6][1].getToken() == token)) {return true;} /*25 - 61*/
else if ((cells[2][6].getToken() == token) && (cells[3][5].getToken() == token) && (cells[4][4].getToken() == token) && (cells[5][3].getToken() == token) && (cells[6][2].getToken() == token)) {return true;} /*26 - 62*/
else if ((cells[2][7].getToken() == token) && (cells[3][6].getToken() == token) && (cells[4][5].getToken() == token) && (cells[5][4].getToken() == token) && (cells[6][3].getToken() == token)) {return true;} /*27 - 63*/
else if ((cells[2][8].getToken() == token) && (cells[3][7].getToken() == token) && (cells[4][6].getToken() == token) && (cells[5][5].getToken() == token) && (cells[6][4].getToken() == token)) {return true;} /*28 - 64*/
else if ((cells[2][9].getToken() == token) && (cells[3][8].getToken() == token) && (cells[4][7].getToken() == token) && (cells[5][6].getToken() == token) && (cells[6][5].getToken() == token)) {return true;} /*29 - 65*/

else if ((cells[3][4].getToken() == token) && (cells[4][3].getToken() == token) && (cells[5][2].getToken() == token) && (cells[6][1].getToken() == token) && (cells[7][0].getToken() == token)) {return true;} /*39 - 75*/
else if ((cells[3][5].getToken() == token) && (cells[4][4].getToken() == token) &

Agak panjang, agar tampilannya lebih rapi, silahkan copas saja ke tect editor atau pengolahan source code kesayangan anda.

Program diatas sudah dilengkapi dengan aturan kemenagan, jika pemain dapat menyusun posisi sebanyak 5 deret secara berturut-turut, maka akan menang. Untuk memainkannya silahkan menuju ke: http://cs.unsyiah.ac.id/~alamri/belajar/TicTacToe/ (KLIK).

Semoga source code diatas dapat berguna, lebih dan kurang saya mohon maaf. Wassalam. ~ Ahmad Ariful Amri

Kamis, 03 Januari 2013

http://go-program.blogspot.com/2013/01/source-code-java-applet-1-game-tictactoe.html
Iseng-iseng saya mencari cara membuat game tictactoe sebagai tugas yang diberikan dosen, ternyata source codenya sudah tertampang di halaman web dosen yang memberikan tugas tersebut. dihalaman tersebut sudah terpampang sebuah applet game tictactoe menggunakan java. Otomatis untuk menampilkan applet dibrowser, dibutuhkan file.class yang merpuakan hasil kompilasi file.java. Nah entah lupa khilaf atau kesalahan sistem, bapak "Pemberi tugas" tidak menutup akses tempat disimpannya file .class tersebut. 

Tentu saja mahasiswa seperti saya tidak bisa mengabaikan source code gratis dari dosen ini, langsung saja saya dowload TicTac.class dan di decompile menggunakan aplikasi java decompiler. Jreeeng Seluruh source code dari dosen terpampang jelas dengan sempurna. Namun source code dibawah ini bukanlah buatan dosen saya, melainkan robor pembuat game tictactoe yang telah dibuat olehnya. Iniah dia source code game TacTicToe Dengan java Applet

/*--------------------------------------------------------*/
/*-----Author : Robot Dosen saya------------------------*/
/*-----Program: Applet Tictactoe--------------------------*/
/*------------http://go-program.blogspot.com--------------*/
/*--------------------------------------------------------*/
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class TicTac extends JApplet
implements ActionListener
{
int x = 10;

JButton[] pp = new JButton[this.x * this.x];
JLabel ln = new JLabel(" Giliran Pemain Pertama");
int w = 1;

public void init() {
setSize(50 * this.x + 5, 50 * this.x + 5);

JPanel pane = new JPanel();
BorderLayout border = new BorderLayout();
pane.setLayout(border);

JPanel paneButton = new JPanel();
paneButton.setLayout(new GridLayout(this.x, this.x, 0, 0));

for (int i = 0; i < this.x * this.x; i++) this.pp[i] = new JButton("");
for (int i = 0; i < this.x * this.x; i++) this.pp[i].addActionListener(this);
for (int i = 0; i < this.x * this.x; i++) paneButton.add(this.pp[i]);

pane.add("Center", paneButton);
pane.add("South", add(this.ln));
setContentPane(pane);
show();
}
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() == this.pp[0]) {
if (this.w == 1) { this.pp[0].setText(" X "); this.pp[0].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[0].setText(" O "); this.pp[0].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[0].setEnabled(false);
} else if (evt.getSource() == this.pp[1]) {
if (this.w == 1) { this.pp[1].setText(" X "); this.pp[1].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[1].setText(" O "); this.pp[1].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[1].setEnabled(false);
} else if (evt.getSource() == this.pp[2]) {
if (this.w == 1) { this.pp[2].setText(" X "); this.pp[2].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[2].setText(" O "); this.pp[2].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[2].setEnabled(false);
} else if (evt.getSource() == this.pp[3]) {
if (this.w == 1) { this.pp[3].setText(" X "); this.pp[3].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[3].setText(" O "); this.pp[3].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[3].setEnabled(false);
} else if (evt.getSource() == this.pp[4]) {
if (this.w == 1) { this.pp[4].setText(" X "); this.pp[4].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[4].setText(" O "); this.pp[4].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[4].setEnabled(false);
} else if (evt.getSource() == this.pp[5]) {
if (this.w == 1) { this.pp[5].setText(" X "); this.pp[5].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[5].setText(" O "); this.pp[5].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[5].setEnabled(false);
} else if (evt.getSource() == this.pp[6]) {
if (this.w == 1) { this.pp[6].setText(" X "); this.pp[6].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[6].setText(" O "); this.pp[6].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[6].setEnabled(false);
} else if (evt.getSource() == this.pp[7]) {
if (this.w == 1) { this.pp[7].setText(" X "); this.pp[7].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[7].setText(" O "); this.pp[7].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[7].setEnabled(false);
} else if (evt.getSource() == this.pp[8]) {
if (this.w == 1) { this.pp[8].setText(" X "); this.pp[8].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[8].setText(" O "); this.pp[8].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[8].setEnabled(false);
} else if (evt.getSource() == this.pp[9]) {
if (this.w == 1) { this.pp[9].setText(" X "); this.pp[9].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[9].setText(" O "); this.pp[9].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[9].setEnabled(false);
} else if (evt.getSource() == this.pp[10]) {
if (this.w == 1) { this.pp[10].setText(" X "); this.pp[10].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[10].setText(" O "); this.pp[10].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[10].setEnabled(false);
} else if (evt.getSource() == this.pp[11]) {
if (this.w == 1) { this.pp[11].setText(" X "); this.pp[11].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[11].setText(" O "); this.pp[11].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[11].setEnabled(false);
} else if (evt.getSource() == this.pp[12]) {
if (this.w == 1) { this.pp[12].setText(" X "); this.pp[12].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[12].setText(" O "); this.pp[12].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[12].setEnabled(false);
} else if (evt.getSource() == this.pp[13]) {
if (this.w == 1) { this.pp[13].setText(" X "); this.pp[13].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[13].setText(" O "); this.pp[13].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[13].setEnabled(false);
} else if (evt.getSource() == this.pp[14]) {
if (this.w == 1) { this.pp[14].setText(" X "); this.pp[14].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[14].setText(" O "); this.pp[14].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[14].setEnabled(false);
} else if (evt.getSource() == this.pp[15]) {
if (this.w == 1) { this.pp[15].setText(" X "); this.pp[15].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[15].setText(" O "); this.pp[15].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[15].setEnabled(false);
} else if (evt.getSource() == this.pp[16]) {
if (this.w == 1) { this.pp[16].setText(" X "); this.pp[16].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[16].setText(" O "); this.pp[16].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[16].setEnabled(false);
} else if (evt.getSource() == this.pp[17]) {
if (this.w == 1) { this.pp[17].setText(" X "); this.pp[17].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[17].setText(" O "); this.pp[17].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[17].setEnabled(false);
} else if (evt.getSource() == this.pp[18]) {
if (this.w == 1) { this.pp[18].setText(" X "); this.pp[18].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[18].setText(" O "); this.pp[18].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[18].setEnabled(false);
} else if (evt.getSource() == this.pp[19]) {
if (this.w == 1) { this.pp[19].setText(" X "); this.pp[19].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[19].setText(" O "); this.pp[19].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[19].setEnabled(false);
} else if (evt.getSource() == this.pp[20]) {
if (this.w == 1) { this.pp[20].setText(" X "); this.pp[20].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[20].setText(" O "); this.pp[20].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[20].setEnabled(false);
} else if (evt.getSource() == this.pp[21]) {
if (this.w == 1) { this.pp[21].setText(" X "); this.pp[21].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[21].setText(" O "); this.pp[21].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[21].setEnabled(false);
} else if (evt.getSource() == this.pp[22]) {
if (this.w == 1) { this.pp[22].setText(" X "); this.pp[22].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[22].setText(" O "); this.pp[22].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[22].setEnabled(false);
} else if (evt.getSource() == this.pp[23]) {
if (this.w == 1) { this.pp[23].setText(" X "); this.pp[23].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[23].setText(" O "); this.pp[23].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[23].setEnabled(false);
} else if (evt.getSource() == this.pp[24]) {
if (this.w == 1) { this.pp[24].setText(" X "); this.pp[24].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[24].setText(" O "); this.pp[24].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[24].setEnabled(false);
} else if (evt.getSource() == this.pp[25]) {
if (this.w == 1) { this.pp[25].setText(" X "); this.pp[25].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[25].setText(" O "); this.pp[25].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[25].setEnabled(false);
} else if (evt.getSource() == this.pp[26]) {
if (this.w == 1) { this.pp[26].setText(" X "); this.pp[26].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[26].setText(" O "); this.pp[26].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[26].setEnabled(false);
} else if (evt.getSource() == this.pp[27]) {
if (this.w == 1) { this.pp[27].setText(" X "); this.pp[27].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[27].setText(" O "); this.pp[27].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[27].setEnabled(false);
} else if (evt.getSource() == this.pp[28]) {
if (this.w == 1) { this.pp[28].setText(" X "); this.pp[28].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[28].setText(" O "); this.pp[28].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[28].setEnabled(false);
} else if (evt.getSource() == this.pp[29]) {
if (this.w == 1) { this.pp[29].setText(" X "); this.pp[29].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[29].setText(" O "); this.pp[29].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[29].setEnabled(false);
} else if (evt.getSource() == this.pp[30]) {
if (this.w == 1) { this.pp[30].setText(" X "); this.pp[30].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[30].setText(" O "); this.pp[30].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[30].setEnabled(false);
} else if (evt.getSource() == this.pp[31]) {
if (this.w == 1) { this.pp[31].setText(" X "); this.pp[31].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[31].setText(" O "); this.pp[31].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[31].setEnabled(false);
} else if (evt.getSource() == this.pp[32]) {
if (this.w == 1) { this.pp[32].setText(" X "); this.pp[32].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[32].setText(" O "); this.pp[32].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[32].setEnabled(false);
} else if (evt.getSource() == this.pp[33]) {
if (this.w == 1) { this.pp[33].setText(" X "); this.pp[33].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[33].setText(" O "); this.pp[33].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[33].setEnabled(false);
} else if (evt.getSource() == this.pp[34]) {
if (this.w == 1) { this.pp[34].setText(" X "); this.pp[34].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[34].setText(" O "); this.pp[34].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[34].setEnabled(false);
} else if (evt.getSource() == this.pp[35]) {
if (this.w == 1) { this.pp[35].setText(" X "); this.pp[35].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[35].setText(" O "); this.pp[35].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[35].setEnabled(false);
} else if (evt.getSource() == this.pp[36]) {
if (this.w == 1) { this.pp[36].setText(" X "); this.pp[36].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[36].setText(" O "); this.pp[36].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[36].setEnabled(false);
} else if (evt.getSource() == this.pp[37]) {
if (this.w == 1) { this.pp[37].setText(" X "); this.pp[37].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[37].setText(" O "); this.pp[37].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[37].setEnabled(false);
} else if (evt.getSource() == this.pp[38]) {
if (this.w == 1) { this.pp[38].setText(" X "); this.pp[38].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[38].setText(" O "); this.pp[38].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[38].setEnabled(false);
} else if (evt.getSource() == this.pp[39]) {
if (this.w == 1) { this.pp[39].setText(" X "); this.pp[39].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[39].setText(" O "); this.pp[39].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[39].setEnabled(false);
} else if (evt.getSource() == this.pp[40]) {
if (this.w == 1) { this.pp[40].setText(" X "); this.pp[40].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[40].setText(" O "); this.pp[40].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[40].setEnabled(false);
} else if (evt.getSource() == this.pp[41]) {
if (this.w == 1) { this.pp[41].setText(" X "); this.pp[41].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[41].setText(" O "); this.pp[41].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[41].setEnabled(false);
} else if (evt.getSource() == this.pp[42]) {
if (this.w == 1) { this.pp[42].setText(" X "); this.pp[42].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[42].setText(" O "); this.pp[42].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[42].setEnabled(false);
} else if (evt.getSource() == this.pp[43]) {
if (this.w == 1) { this.pp[43].setText(" X "); this.pp[43].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[43].setText(" O "); this.pp[43].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[43].setEnabled(false);
} else if (evt.getSource() == this.pp[44]) {
if (this.w == 1) { this.pp[44].setText(" X "); this.pp[44].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[44].setText(" O "); this.pp[44].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[44].setEnabled(false);
} else if (evt.getSource() == this.pp[45]) {
if (this.w == 1) { this.pp[45].setText(" X "); this.pp[45].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[45].setText(" O "); this.pp[45].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[45].setEnabled(false);
} else if (evt.getSource() == this.pp[46]) {
if (this.w == 1) { this.pp[46].setText(" X "); this.pp[46].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[46].setText(" O "); this.pp[46].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[46].setEnabled(false);
} else if (evt.getSource() == this.pp[47]) {
if (this.w == 1) { this.pp[47].setText(" X "); this.pp[47].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[47].setText(" O "); this.pp[47].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[47].setEnabled(false);
} else if (evt.getSource() == this.pp[48]) {
if (this.w == 1) { this.pp[48].setText(" X "); this.pp[48].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[48].setText(" O "); this.pp[48].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[48].setEnabled(false);
} else if (evt.getSource() == this.pp[49]) {
if (this.w == 1) { this.pp[49].setText(" X "); this.pp[49].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[49].setText(" O "); this.pp[49].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[49].setEnabled(false);
} else if (evt.getSource() == this.pp[50]) {
if (this.w == 1) { this.pp[50].setText(" X "); this.pp[50].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[50].setText(" O "); this.pp[50].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[50].setEnabled(false);
} else if (evt.getSource() == this.pp[51]) {
if (this.w == 1) { this.pp[51].setText(" X "); this.pp[51].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[51].setText(" O "); this.pp[51].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[51].setEnabled(false);
} else if (evt.getSource() == this.pp[52]) {
if (this.w == 1) { this.pp[52].setText(" X "); this.pp[52].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[52].setText(" O "); this.pp[52].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[52].setEnabled(false);
} else if (evt.getSource() == this.pp[53]) {
if (this.w == 1) { this.pp[53].setText(" X "); this.pp[53].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[53].setText(" O "); this.pp[53].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[53].setEnabled(false);
} else if (evt.getSource() == this.pp[54]) {
if (this.w == 1) { this.pp[54].setText(" X "); this.pp[54].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[54].setText(" O "); this.pp[54].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[54].setEnabled(false);
} else if (evt.getSource() == this.pp[55]) {
if (this.w == 1) { this.pp[55].setText(" X "); this.pp[55].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[55].setText(" O "); this.pp[55].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[55].setEnabled(false);
} else if (evt.getSource() == this.pp[56]) {
if (this.w == 1) { this.pp[56].setText(" X "); this.pp[56].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[56].setText(" O "); this.pp[56].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[56].setEnabled(false);
} else if (evt.getSource() == this.pp[57]) {
if (this.w == 1) { this.pp[57].setText(" X "); this.pp[57].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[57].setText(" O "); this.pp[57].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[57].setEnabled(false);
} else if (evt.getSource() == this.pp[58]) {
if (this.w == 1) { this.pp[58].setText(" X "); this.pp[58].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[58].setText(" O "); this.pp[58].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[58].setEnabled(false);
} else if (evt.getSource() == this.pp[59]) {
if (this.w == 1) { this.pp[59].setText(" X "); this.pp[59].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[59].setText(" O "); this.pp[59].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[59].setEnabled(false);
} else if (evt.getSource() == this.pp[60]) {
if (this.w == 1) { this.pp[60].setText(" X "); this.pp[60].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[60].setText(" O "); this.pp[60].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[60].setEnabled(false);
} else if (evt.getSource() == this.pp[61]) {
if (this.w == 1) { this.pp[61].setText(" X "); this.pp[61].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[61].setText(" O "); this.pp[61].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[61].setEnabled(false);
} else if (evt.getSource() == this.pp[62]) {
if (this.w == 1) { this.pp[62].setText(" X "); this.pp[62].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[62].setText(" O "); this.pp[62].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[62].setEnabled(false);
} else if (evt.getSource() == this.pp[63]) {
if (this.w == 1) { this.pp[63].setText(" X "); this.pp[63].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[63].setText(" O "); this.pp[63].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[63].setEnabled(false);
} else if (evt.getSource() == this.pp[64]) {
if (this.w == 1) { this.pp[64].setText(" X "); this.pp[64].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[64].setText(" O "); this.pp[64].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[64].setEnabled(false);
} else if (evt.getSource() == this.pp[65]) {
if (this.w == 1) { this.pp[65].setText(" X "); this.pp[65].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[65].setText(" O "); this.pp[65].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[65].setEnabled(false);
} else if (evt.getSource() == this.pp[66]) {
if (this.w == 1) { this.pp[66].setText(" X "); this.pp[66].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[66].setText(" O "); this.pp[66].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[66].setEnabled(false);
} else if (evt.getSource() == this.pp[67]) {
if (this.w == 1) { this.pp[67].setText(" X "); this.pp[67].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[67].setText(" O "); this.pp[67].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[67].setEnabled(false);
} else if (evt.getSource() == this.pp[68]) {
if (this.w == 1) { this.pp[68].setText(" X "); this.pp[68].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[68].setText(" O "); this.pp[68].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[68].setEnabled(false);
} else if (evt.getSource() == this.pp[69]) {
if (this.w == 1) { this.pp[69].setText(" X "); this.pp[69].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[69].setText(" O "); this.pp[69].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[69].setEnabled(false);
} else if (evt.getSource() == this.pp[70]) {
if (this.w == 1) { this.pp[70].setText(" X "); this.pp[70].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[70].setText(" O "); this.pp[70].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[70].setEnabled(false);
} else if (evt.getSource() == this.pp[71]) {
if (this.w == 1) { this.pp[71].setText(" X "); this.pp[71].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[71].setText(" O "); this.pp[71].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[71].setEnabled(false);
} else if (evt.getSource() == this.pp[72]) {
if (this.w == 1) { this.pp[72].setText(" X "); this.pp[72].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[72].setText(" O "); this.pp[72].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[72].setEnabled(false);
} else if (evt.getSource() == this.pp[73]) {
if (this.w == 1) { this.pp[73].setText(" X "); this.pp[73].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[73].setText(" O "); this.pp[73].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[73].setEnabled(false);
} else if (evt.getSource() == this.pp[74]) {
if (this.w == 1) { this.pp[74].setText(" X "); this.pp[74].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[74].setText(" O "); this.pp[74].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[74].setEnabled(false);
} else if (evt.getSource() == this.pp[75]) {
if (this.w == 1) { this.pp[75].setText(" X "); this.pp[75].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[75].setText(" O "); this.pp[75].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[75].setEnabled(false);
} else if (evt.getSource() == this.pp[76]) {
if (this.w == 1) { this.pp[76].setText(" X "); this.pp[76].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[76].setText(" O "); this.pp[76].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[76].setEnabled(false);
} else if (evt.getSource() == this.pp[77]) {
if (this.w == 1) { this.pp[77].setText(" X "); this.pp[77].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[77].setText(" O "); this.pp[77].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[77].setEnabled(false);
} else if (evt.getSource() == this.pp[78]) {
if (this.w == 1) { this.pp[78].setText(" X "); this.pp[78].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[78].setText(" O "); this.pp[78].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[78].setEnabled(false);
} else if (evt.getSource() == this.pp[79]) {
if (this.w == 1) { this.pp[79].setText(" X "); this.pp[79].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[79].setText(" O "); this.pp[79].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[79].setEnabled(false);
} else if (evt.getSource() == this.pp[80]) {
if (this.w == 1) { this.pp[80].setText(" X "); this.pp[80].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[80].setText(" O "); this.pp[80].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[80].setEnabled(false);
} else if (evt.getSource() == this.pp[81]) {
if (this.w == 1) { this.pp[81].setText(" X "); this.pp[81].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[81].setText(" O "); this.pp[81].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[81].setEnabled(false);
} else if (evt.getSource() == this.pp[82]) {
if (this.w == 1) { this.pp[82].setText(" X "); this.pp[82].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[82].setText(" O "); this.pp[82].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[82].setEnabled(false);
} else if (evt.getSource() == this.pp[83]) {
if (this.w == 1) { this.pp[83].setText(" X "); this.pp[83].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[83].setText(" O "); this.pp[83].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[83].setEnabled(false);
} else if (evt.getSource() == this.pp[84]) {
if (this.w == 1) { this.pp[84].setText(" X "); this.pp[84].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[84].setText(" O "); this.pp[84].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[84].setEnabled(false);
} else if (evt.getSource() == this.pp[85]) {
if (this.w == 1) { this.pp[85].setText(" X "); this.pp[85].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[85].setText(" O "); this.pp[85].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[85].setEnabled(false);
} else if (evt.getSource() == this.pp[86]) {
if (this.w == 1) { this.pp[86].setText(" X "); this.pp[86].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[86].setText(" O "); this.pp[86].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[86].setEnabled(false);
} else if (evt.getSource() == this.pp[87]) {
if (this.w == 1) { this.pp[87].setText(" X "); this.pp[87].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[87].setText(" O "); this.pp[87].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[87].setEnabled(false);
} else if (evt.getSource() == this.pp[88]) {
if (this.w == 1) { this.pp[88].setText(" X "); this.pp[88].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[88].setText(" O "); this.pp[88].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[88].setEnabled(false);
} else if (evt.getSource() == this.pp[89]) {
if (this.w == 1) { this.pp[89].setText(" X "); this.pp[89].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[89].setText(" O "); this.pp[89].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[89].setEnabled(false);
} else if (evt.getSource() == this.pp[90]) {
if (this.w == 1) { this.pp[90].setText(" X "); this.pp[90].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[90].setText(" O "); this.pp[90].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[90].setEnabled(false);
} else if (evt.getSource() == this.pp[91]) {
if (this.w == 1) { this.pp[91].setText(" X "); this.pp[91].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[91].setText(" O "); this.pp[91].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[91].setEnabled(false);
} else if (evt.getSource() == this.pp[92]) {
if (this.w == 1) { this.pp[92].setText(" X "); this.pp[92].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[92].setText(" O "); this.pp[92].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[92].setEnabled(false);
} else if (evt.getSource() == this.pp[93]) {
if (this.w == 1) { this.pp[93].setText(" X "); this.pp[93].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[93].setText(" O "); this.pp[93].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[93].setEnabled(false);
} else if (evt.getSource() == this.pp[94]) {
if (this.w == 1) { this.pp[94].setText(" X "); this.pp[94].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[94].setText(" O "); this.pp[94].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[94].setEnabled(false);
} else if (evt.getSource() == this.pp[95]) {
if (this.w == 1) { this.pp[95].setText(" X "); this.pp[95].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[95].setText(" O "); this.pp[95].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[95].setEnabled(false);
} else if (evt.getSource() == this.pp[96]) {
if (this.w == 1) { this.pp[96].setText(" X "); this.pp[96].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[96].setText(" O "); this.pp[96].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[96].setEnabled(false);
} else if (evt.getSource() == this.pp[97]) {
if (this.w == 1) { this.pp[97].setText(" X "); this.pp[97].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[97].setText(" O "); this.pp[97].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[97].setEnabled(false);
} else if (evt.getSource() == this.pp[98]) {
if (this.w == 1) { this.pp[98].setText(" X "); this.pp[98].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[98].setText(" O "); this.pp[98].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[98].setEnabled(false);
} else if (evt.getSource() == this.pp[99]) {
if (this.w == 1) { this.pp[99].setText(" X "); this.pp[99].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[99].setText(" O "); this.pp[99].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[99].setEnabled(false);
} else if (evt.getSource() == this.pp[100]) {
if (this.w == 1) { this.pp[100].setText(" X "); this.pp[100].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[100].setText(" O "); this.pp[100].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[100].setEnabled(false);
}
}
}

Source codenya Agak panjang ya, udah panjang namun fiturnya masih belum keren. Belum ada sistem kemenangan, Sehingga hanya untuk asal asal klik saja tanpa ada aturan menang. Untuk melihat atau jika anda ingin memainkannya, dapat menuju ke: http://cs.unsyiah.ac.id/~alamri/belajar/TicTac/ (KLIK)

Karena kurang puas, akhirnya tetap saja saya tidak menggunakan source code ini untuk mengumpulkan tugas. Tapi tetap saja googling dan mencari pencerahan. Entar source code game TicTacToe saya, akan diposting pada artikel selanjutnya. Semoga pembahasan kali ini bisa berguna ya.. :)

Selasa, 01 Januari 2013

http://go-program.blogspot.com/2013/01/membuat-panel-dan-button-game-applet-tictactoe-java.html
Menyambung persoalan tugas yang telah selesai, kali ini saya hanya akan mengulas sedikit tentang proses pembuatan tugas membuat game tictactoe. Pada postingan ini membahas tahap sederhana pembuatan game tictactoe, yaitu membuat panel dan button untuk game tictactoe, disini diharuskan mengimport yang namanya java.awt dan javax.swing. 

agar lebih mudah memahami, silahkan lihat saja sourcecode berikut ini.
/*--------------------------------------------------------*/
/*-----Nama : Ahmad Ariful Amri ------------------------*/
/*-----Program: membuat panel dan button game tictactoe---*/
/*------------http://go-program.blogspot.com--------------*/
/*--------------------------------------------------------*/
import java.awt.*;
import java.awt.event.*;
import java.awt.GridLayout;
import javax.swing.*;
import javax.swing.border.LineBorder;

public class PanelButton extends JApplet
{
JButton[][] button = new JButton[10][10];

public void init()
{
JPanel p = new JPanel();
p.setBackground(Color.blue);
p.setLayout(new GridLayout(10, 10, 0, 0));
for (int i=0; i<10; i++)
for (int j=0; j<10; j++)
p.add(button[i][j] = new JButton());

p.setBorder(new LineBorder(Color.red, 1));
this.getContentPane().add(p, BorderLayout.CENTER);
}

}

Untuk melihat hasil dari program diatas silahkan lihat appletnya di: http://cs.unsyiah.ac.id/~alamri/belajar/tictac/ Nah, penjelasan sourcecode diatas saya kira masih dapat dipahami, jika belum begini:

Untuk mengaktifkan berbagai fungsi/method pada SC diatas, kita harus mengimport :

import java.awt.*;
import java.awt.event.*;
import java.awt.GridLayout;
import javax.swing.*;
import javax.swing.border.LineBorder;

Selanjutnya, untuk membuat sebuah wadah atau tempat diletakkannya isi game tersebut, membutuhkan class JPanel, Jpanel sendiri sebenarnya berna,a Panel saja, cum karena disini dijalankan menggunakan browser, karena ada javax.swing. maka semua komponen swing ditambahkan J didepannya.


p.setBackground(Color.blue);

digunakan untuk membuat backgrond, backgroundnya diberi warna biru.


p.setLayout(new GridLayout(10, 10, 0, 0));

Pada halaman nya diberika grid, atau seperti pembatas garis garis


 for (int i=0; i<10; i++)
for (int j=0; j<10; j++)
p.add(button[i][j] = new JButton());


Menambahkan button atau tombol yang dapat diklik.

Semoga tutorial sederhana diatas dapat berguna

Jumat, 07 Desember 2012

http://go-program.blogspot.com/2012/12/menulis-string-ke-dalam-file-txt-menggunakan-java.html
Ada banyak sekali fungsi dari Input Output dalam java yang dapat digunakan untuk mencetak String, char, ataupun jenis data lainnua kedalam sebuah file.txt. pada kesempatan kali ini, akan diposting 2 buah contoh sederhana untuk membuat sebuah file txt menggunakan Java. yang satu menggunakan bufferedwriter, dan  write FileOutputStream biasa.
1. Cetak.java
/*----------------------------------------------------------------*/
/*-------------Nama : Ahmad Ariful Amri ------------------------*/
/*-------------Program: Mencetak string kedalam sebuah file-------*/
/*-----------------visit: go-program.blogspot.com-----------------*/
/*----------------------------------------------------------------*/
import java.io.*;

public class Cetak
{
public static void main(String args[])throws IOException
{
Writer output = null;
String text = "Percoban menulis String ke dalam file.txt";
File file = new File("file.txt");
output = new BufferedWriter(new FileWriter(file));
output.write(text);
output.close();

System.out.println("Tulisan anda sudah di tulis ke " +file);
}
}
2. Cetak3.java
/*----------------------------------------------------------------*/
/*-------------Nama : Ahmad Ariful Amri ------------------------*/
/*-------------Program: Mencetak string kedalam sebuah file-------*/
/*-----------------visit: go-program.blogspot.com-----------------*/
/*----------------------------------------------------------------*/

import java.io.*;

public class Cetak3
{
public void tulis(String pesan,String namaBerkas) throws IOException
{
FileOutputStream keluaran = null;

try
{
keluaran = new FileOutputStream(namaBerkas);
for(int cacah = 0; cacah<pesan.length(); ++cacah)
{
int karakter = pesan.charAt(cacah);
keluaran.write(karakter);
}
}
finally
{
if(keluaran !=null)
{
keluaran.close();
}
}
}

public static void main (String args[]) throws IOException
{
try
{
Cetak3 tulisBerkas = new Cetak3();
tulisBerkas.tulis("Percobaan menulis String kedalam file", "Cetak3.txt");
}
catch(IOException kesalahan)
{
System.out.printf("Terjadi kesalahan %s", kesalahan);
}
}
}
Banyak sekali cara lain yang dapat digunakan untuk mencetak file menggunakan java, silahkan berkreasi

Senin, 03 Desember 2012

Selection Sort
Pada postingan sebelumnya sudah dibahas mengenai algoritma dan contoh program mengurutkan data menggunakan metode Bubble Sort. Nah postingan kali ini membahas pengurutan data secara ascending menggunakan metode sorting selection Sort. Jika masih belum mengerti algoritma Selection Sort, dapat membaca kembali artikel Algortima Sorting Metode Selection Sort. Disini hanya membahas cara implementasinya aja, berikut conth implementasi mengurutkan data menggunakan meode selection Sort.

/*--------------------------------------------------------------*/
/*-----------Nama : Ahmad Ariful Amri ------------------------*/
/*-----------Program: Pengurutan data dengan Selection Sort ----*/
/*---------------visit: go-program.blogspot.com-----------------*/
/*--------------------------------------------------------------*/

#include <stdio.h>

int main()
{
int data[100], n, i, j, position, swap;

printf("Masukkan Jumlah data : ");
scanf("%d", &n);

printf("nMasukkan %d datan", n);

for ( i=0 ; i<n ; i++ )
{
printf("Data ke %d : ", i+1);
scanf("%d", &data[i]);
}

for ( i=0 ; i<(n-1) ; i++ )
{
position=i;

for (j=i+1; j<n ; j++)
{
if ( data[position] > data[j] )
position=j;
}
if ( position != i )
{
swap = data[i];
data[i] = data[position];
data[position] = swap;
}
}

printf("Data setelah diurutkan:n");

for ( i=0 ; i<n ; i++ )
{
printf("%dt", data[i]);
}

return 0;
}