Δημοσιεύτηκε: 21 Αύγ 2010, 11:55
από M.Jackson
Ενα απλο παιχνιδακι στην java

Κώδικας: Επιλογή όλων
import javax.swing.JOptionPane;
import java.util.Random;

public class pro{
public static void main (String args []) throws Exception{

Random rnd = new Random();

int x=0;
String get;
int geted;

do{
for(int i=1; i<=10; i++){
x=rnd.nextInt(10);}

get = JOptionPane.showInputDialog("Dose ton arithmo sou");

geted = Integer.parseInt(get);

if(geted == x){
JOptionPane.showMessageDialog(null,"Well Done!");
}else{
JOptionPane.showMessageDialog(null,"Game Over! o arithmos sou ine: " + geted + " kai o randomize arithmos ine: " + x);}
}while(geted!=x);
}}