⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 21点游戏后台运行处理程序
💻 JAVA
字号:
package game;

public class main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自动生成方法存根
   player1 a=new player1();   //调用类1(激进玩家)
   int last1=a.result();       //保存调用类1结果
   if(last1==21)   //判断玩家1点数是否为21点
   {
	   System.out.println("player1's score is 21");
	   System.out.println("the winner is player1!");   //玩家1点数21点,判定玩家1胜利
   }
   else{        //否则对下面的玩家进行判断(因为此时玩家1点数超过21,判定输)
   player2 b=new player2();  //调用类2(保守玩家)
   player3 c= new player3();   //调用类3(智慧玩家)
   man m=new man();             //调用类4(人类)
   
   int last2=b.result();
   int last3=c.result();
   int last4=m.result();     //保存相关类的调用数据
   if(last2<=21&&last3>21&&last4>21)
   {
	   System.out.println("player2's score is "+last2);
	   System.out.println("the winner is player2!");   //当其他玩家超过21点时,判定玩家2胜利
   }
   if(last3<=21&&last2>21&&last4>21)
   {
	   System.out.println("player3's score is "+last3);
	   System.out.println("the winner is player3!");   //同上判定方法,判定玩家3胜利
   }
   if(last4<=21&&last2>21&&last3>21)
   {
	   System.out.println("your score is "+last4);
	   System.out.println("the winner is you!"); //同上判定方法,判定玩家4胜利
   }
   if(last3>21&&(last2<last4))
   {
	   System.out.println("your score is "+last4);
	   System.out.println("the winner is you!"); //当玩家3超过21点时,玩家2与人类进行比较
   }
   if(last3>21&&(last2>=last4))
   {
	   System.out.println("player2's score is "+last2);
	   System.out.println("the winner is player2!");  //同上
   }
   if(last2<=21&&last3<=21&&last4<=21){  //当玩家2,3,4都少于21点时,比较判断谁的点数最多
	   System.out.println("player2's score is "+last2);
	   System.out.println("player3's score is "+last3);
	   System.out.println("your score is "+last4);
   if((last2>=last3)&&(last2>=last4)){System.out.println("the winner is player2!");}
   if((last3>=last2)&&(last3>=last4)){System.out.println("the winner is player3!");}
   else System.out.println("the winner is you!");
	}
	}
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -