Geri git   Van.GEN.TR Forum | Yerel Van Forumu > Bilgisayar > Programlama > Javascript

Cevapla
 
Konu Araçları Stil
Alt 06/02/08, 21:03   #1
KAYIP__
Orgeneral
 
KAYIP__ - ait Kullanıcı Resmi (Avatar)
 
Üyelik tarihi: Apr 2007
Mesajlar: 4.297
Tecrübe Puanı: 106 KAYIP__ has a reputation beyond repute KAYIP__ has a reputation beyond repute KAYIP__ has a reputation beyond repute KAYIP__ has a reputation beyond repute KAYIP__ has a reputation beyond repute KAYIP__ has a reputation beyond repute KAYIP__ has a reputation beyond repute KAYIP__ has a reputation beyond repute KAYIP__ has a reputation beyond repute KAYIP__ has a reputation beyond repute KAYIP__ has a reputation beyond repute
Thumbs up Javada bir oyun sayi tahmin

import java.applet.*;

import java.awt.event.*;

public class so extends Applet {

sayioyun oyun=new sayioyun();

TextArea output=new TextArea(17,32);

TextField edit=new TextField(4);

char c[]=oyun.sayiuret();



public void yenioyun(){

c=oyun.sayiuret();

}

public static String kontrol(char veri[]){

String mesaj="ok";

if (veri.length!=4)
mesaj="Lutfen 4 basamakli sayi giriniz..";

else {

for(int i=0;i<4;i++){

for(int j=0;j<i;j++){

if ((i!=j) && (veri[i]==veri[j]))
mesaj="Rakamlar birbirinden farkli olmali";

}

}

}

return mesaj;

}

public void init(){

setBackground(new Color(0x33,0x77,0xFF));

Label lb=new Label("Sayı Giriniz : ");

lb.setFont(new Font

("Helvetica",Font.BOLD,11));

lb.setForeground(new Color(0xEE,0xDD,0xEE));

add(lb);

edit.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

String kontrolmes=

kontrol(edit.getText().toCharArray());

if (kontrolmes.equals("ok")) {

char g[]=edit.getText().toCharArray();

output.appendText(" "+edit.getText());

output.appendText(" : "+oyun.karsilastir(c,g));

} else {

output.appendText(" "+kontrolmes); } output.appendText("\n");

edit.setText("");

}

});

edit.setForeground(new Color(0xEE,0xEE,0xDD));

edit.setFont(new Font("Helvetica",Font.BOLD,11));

add(edit);

Button yn=new Button("Yeni Oyun");

yn.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

yenioyun();

output.setText("");

edit.setText("");

}

});

yn.setBackground(new Color(0x55,0x77,0x99));

yn.setForeground(new Color(0xEE,0xEE,0xDD));

yn.setFont(new Font("Helvetica",Font.BOLD,11));

add(yn);

output.setForeground(new Color(0xFF,0xFF,0x10));

output.setFont(new Font("Helvetica",Font.BOLD,11));

add(output);

Label imza=new Label("CopyRight (c) Adem ÖZER 2004");

imza.setFont(new Font("Helvetica",Font.BOLD,10));

imza.setForeground(new Color(0xEE,0xDD,0xEE));

add(imza);

}

}



class sayioyun {

int rasgelesayi(){

int a=(int)(Math.random()*10);

return a;

}

public boolean varmi(char ch,char d[],int uz){

for(int i=0;i<uz;i++){

if (d[i]==ch) return true;

}

return false;

}

public char[] sayiuret(){

char c[],k[];

k=new char[4];

for(int i=0;i<4;i++) {

int j=0;

do {

Integer b=new Integer(rasgelesayi());

c=b.toString().toCharArray();

j++;

} while((k[j]==c[0]) && (j<i)) ;



if (!varmi(c[0],k,i)){

k[i]=c[0];

} else {i--;}

}

return k;

}



public static String karsilastir(char kaynak[],char hedef[]){

int neg=0,poz=0;

String mesaj;

for(int i=0;i<4;i++){

if(kaynak[i]==hedef[i]) poz++;

for(int j=0;j<4;j++) {

if ((i!=j) && (kaynak[i]==hedef[j])) neg++;

}

}

if(poz!=4){

mesaj="+"+poz+" -"+neg;

} else {mesaj="ok Bravo Bildiniz..";}

return mesaj;

}

}
__________________

KAYIP__ isimli Üye şimdilik offline konumundadır   Alıntı ile Cevapla
Konu Sayısı: 1143
Takımınız:
Alt 01/08/08, 10:15   #2
Neutralizer
Yasaklı kullanıcı
 
Neutralizer - ait Kullanıcı Resmi (Avatar)
 
Üyelik tarihi: Jan 2008
Bulunduğu yer: İstediğin yerden
Mesajlar: 1.890
Tecrübe Puanı: 0 Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute
Standart

paylaşım için tşkrlr
Neutralizer isimli Üye şimdilik offline konumundadır   Alıntı ile Cevapla
Konu Sayısı: 317
Takımınız:
Cevapla


Konuyu Toplam 1 Üye okuyor. (0 Kayıtlı üye ve 1 Misafir)
 
Konu Araçları
Stil

Yetkileriniz
Yeni Mesaj yazma yetkiniz Aktif değil dir.
Mesajlara Cevap verme yetkiniz aktif değil dir.
Eklenti ekleme yetkiniz Aktif değil dir.
Kendi Mesajınızı değiştirme yetkiniz Aktif değildir dir.

BB code is Açık
Smileler Açık
[IMG] Kodları Açık
HTML-KodlarıKapalı
Gitmek istediğiniz klasörü seçiniz


Bütün Zaman Ayarları WEZ +3 olarak düzenlenmiştir. Şu Anki Saat: 17:00 .


Powered by vBulletin
Copyright © 2000-2007 Jelsoft Enterprises Limited.
Sitemap
6, 5, 3, 7, 8, 9, 10, 11, 12, 13, 14, 15, 113, 16, 17, 18, 19, 81, 20, 27, 22, 23, 24, 25, 26, 48, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 136, 40, 58, 45, 42, 44, 46, 47, 53, 54, 55, 56, 57, 59, 60, 70, 61, 62, 63, 64, 65, 66, 68, 69, 71, 72, 74, 75, 76, 77, 78, 79, 80, 82, 83, 96, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 98, 97, 100, 101, 102, 103, 106, 104, 105, 112, 109, 108, 107, 110, 111, 114, 115, 118, 116, 117, 119, 148, 154, 124, 165, 122, 120, 123, 121, 150, 153, 125, 128, 129, 131, 132, 133, 134, 135, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 151, 149, 202, 175, 164, 152, 167, 155, 156, 157, 158, 159, 160, 161, 162, 163, 195, 169, 166, 168, 170, 171, 172, 199, 174, 173, 196, 200, 176, 177, 180, 178, 179, 182, 189, 187, 184, 186, 191, 192, 193, 194, 197, 198, 201, 203, 229, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 236, 231, 232, 233, 234, 235, 237, 240, 239, 241, 243, 242, 244,