Untitled
لعبة بالجافاunknown
plain_text
2 years ago
4.2 kB
4
Indexable
import javax.swing.JOptionPane; /* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template */ /** * * @author attasam */ public class JavaApplication4 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int numPlayers,selectGame,maxNum=0,gameChoice,max=0; String t=" ",info=" "; char stop='0'; do{ selectGame=Integer.parseInt(JOptionPane.showInputDialog(" ادخل خيارات اللعبة"+"(1 - 2)")); }while(selectGame<1 || selectGame>2); switch(selectGame){ case 1:{ do{ gameChoice=Integer.parseInt(JOptionPane.showInputDialog("ادخل صفر في حال تريد انهاء اللعبة بدون تحديد سقف")); }while(gameChoice<0); if(gameChoice !=0){ do{ maxNum=Integer.parseInt(JOptionPane.showInputDialog(" ادخل السقف الاعلى ")); }while (maxNum<1); } else{ gameChoice=0; } do{ numPlayers=Integer.parseInt(JOptionPane.showInputDialog(" ادخل عدد اللاعبين")); }while(numPlayers<1); String names[]=new String[numPlayers];///اسماء اللاعبين int score[]=new int[numPlayers];///درجات اللاعبين int res[]=new int[numPlayers];////لحفظ درجات اللاعبين for(int i=0; i<names.length; i++){ names[i]=JOptionPane.showInputDialog(" ادخل اسم اللاعب"+(i+1)); } while(stop=='0'){ for(int m=0;m<names.length;m++){ do{ score[m]=Integer.parseInt(JOptionPane.showInputDialog(" ادخل درجة اللاعب"+" "+ names[m])); }while(score[m]<0); res[m]+=score[m]; if(res[m]>=maxNum && gameChoice!=0 ){ stop='1'; } } if(gameChoice==0){ int c; do{ c=Integer.parseInt(JOptionPane.showInputDialog(" هل تريد الانهاء اضغط صفر")); }while(c<0); if(c==0) stop='1'; else stop='0'; } } for(int k=0; k<res.length;k++){ if(max==res[k]){ max=res[k]; t="تعادل"; } if (max<res[k]){ max=res[k]; // names[k]; } info +=""+names[k]+" "+res[k]+"\n"; // JOptionPane.showMessageDialog(null,names[k]+" "+res[k]+"\n"); } //score[i]=Integer.parseInt(JOptionPane.showInputDialog(" ادخل درجة اللاعب"+" "+ names[i])); // info +=names[i]+" "+score[i] +"\n"; JOptionPane.showMessageDialog(null, info+" اعلى درجة "+max+" "+t); break; } case 2:{ JOptionPane.showMessageDialog(null,"جاري العمل على انشاء حاسبة للبلوت"); break; } } } }
Editor is loading...