21点游戏面向对象实现

21点游戏Java实现

这是21点四人游戏,开局每人发两张牌,一张明牌和一张暗牌,然后依次询问每个人是否要牌(输入false为要牌),当所有人输入true时,进行牌类比较,确定输赢

*后续会完善*
package point21;
import java.util.Scanner;
public class point21_escape {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		APuck temp1;
		APuck temp2;
		APuck temp3;
		APuck temp4;
		System.out.println("欢迎来到《有间竞技场之电锯求生》");
		System.out.println("竞技规则:你们四个人面前有一把电锯,由电脑操控,赢了的人才能活下去,祝你好运");
		System.out.println("游戏开始!");
		temp1=new APuck();
		temp2=new APuck();
		temp3=new APuck();
		temp4=new APuck();
		Computer computer=new Computer();//给四个人各发一张暗牌和明牌
		Puck.makePuck();
		Player p1=new Player();//将Player...,Computer,Puck实例化
		Player p2=new Player();
		Player p3=new Player(); 
		Player p4=new Player();
		System.out.println("给四个人各发一张暗牌和明牌");
		computer.initial(p1,p2,p3,p4);
		temp1=p1.gettingHiden();
		System.out.println("p1的暗牌是: "+temp1.type+temp1.content+"(仅自己可见)");
		System.out.print("p1的明牌是: ");
		for(int j=0;j<p1.n;j++)
		{
			System.out.print(p1.appear[j].type+p1.appear[j].content+" ");
		}
		System.out.println("  "+p1.countAppear+"点"+"\n");
		temp2=p2.gettingHiden();
		System.out.println("p2的暗牌是: "+temp2.type+temp2.content+"(仅自己可见)");
		System.out.print("p2的明牌是: ");
		for(int j=0;j<p2.n;j++)
		{
			System.out.print(p2.appear[j].type+p2.appear[j].content+" ");
		}
		System.out.println("  "+p2.countAppear+"点"+"\n");
		temp3=p3.gettingHiden();
		System.out.println("p3的暗牌是: "+temp3.type+temp3.content+"(仅自己可见)");
		System.out.print("p3的明牌是: ");
		for(int j=0;j<p3.n;j++)
		{
			System.out.print(p3.appear[j].type+p3.appear[j].content+" ");
		}
		System.out.println("  "+p3.countAppear+"点"+"\n");
		temp4=p4.gettingHiden();
		System.out.println("p4的暗牌是: "+temp4.type+temp4.content+"(仅自己可见)");
		System.out.print("p4的明牌是: ");
		for(int j=0;j<p4.n;j++)
		{
			System.out.print(p4.appear[j].type+
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值