Untitled
unknown
plain_text
3 years ago
5.0 kB
10
Indexable
import javax.swing.JOptionPane;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author CTI
*/
public class JavaApplication8 {
/**
* @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=" ",wonTeam=" ";
char r='1';
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 ){
for(int n=score[m];n<names.length;n++){
res[m]+=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="تعادل"+" ";
// r='1';
wonTeam=" ";
}else
{
r='2';
}
if (max<res[k]){
max=res[k];
// names[k];
wonTeam ="اللاعب الاعلى "+" "+names[k];
}
/*if(r!='1'){
wonTeam +="اللاعب الاعلى "+" "+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+wonTeam);
break;
}
case 2:{
JOptionPane.showMessageDialog(null,"جاري العمل على انشاء حاسبة للبلوت");
break;
}
}
}
}
---------------------------------------------
public class JavaApplication9 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int c;
do{
c=Integer.parseInt(JOptionPane.showInputDialog(" "));
}while(c<=0);
for(int i=0;i<=c; i++)
{
for(int j=1; j<=c-i; j++){
System.out.print(j);
}
System.out.println("");
}
}
}
Editor is loading...