java 博饼 算法_博饼算法

while (true)

{

Console.ReadLine();

string result = "";

Random ran = new Random();

for (int i = 0; i < 6; i++) result += ran.Next(1, 7).ToString();

Console.WriteLine(result);

int one = result.Count(r => r == '1');

int two = result.Count(r => r == '2');

int three = result.Count(r => r == '3');

int four = result.Count(r => r == '4');

int five = result.Count(r => r == '5');

int sex = result.Count(r => r == '6');

if (four == 6) Console.WriteLine("六杯红");

else if (four == 4 && one == 2) Console.WriteLine("插金花");

else if (one == 6) Console.WriteLine("遍地锦");

else if (sex == 6 || five == 6 || three == 6 || two == 6) Console.WriteLine("黑六勃");

else if (four == 5 && one == 1) Console.WriteLine("五红");

else if (sex == 5 || five == 5 || three == 5 || two == 5 || one == 5) Console.WriteLine("五子登科");

else if (four == 4) Console.WriteLine("四点红");

else if (one == 1 && two == 1 && three == 1 && four == 1 && five == 1 && sex == 1) Console.WriteLine("对堂");

else if (one == 4 || two == 4 || three == 4 || five == 4 || sex == 4) Console.WriteLine("四进");

else if (four == 3) Console.WriteLine("三红");

else if (four == 2) Console.WriteLine("二举");

else if (four == 1) Console.WriteLine("一秀");

else Console.WriteLine("谢谢参与");

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
博饼是一种传统的中国民间游戏,也可以作为一种小游戏在Java中实现。在博饼游戏中,玩家通过掷骰子来获得不同的点数组合,根据不同的点数组合来判断获得的奖励或者惩罚。 在Java中实现博饼小游戏,可以按照以下步骤进行: 1. 创建一个Dice类,用于表示骰子。该类可以包含一个roll()方法,用于随机生成一个1到6之间的整数作为骰子的点数。 2. 创建一个Player类,用于表示玩家。该类可以包含一个rollDice()方法,用于掷骰子并返回点数组合。 3. 创建一个Game类,用于控制游戏的进行。该类可以包含一个start()方法,用于开始游戏。在游戏进行过程中,可以通过调用Player类的rollDice()方法来获取玩家的点数组合,并根据不同的点数组合来判断奖励或者惩罚。 下面是一个简单的示例代码: ```java import java.util.Random; class Dice { public int roll() { Random random = new Random(); return random.nextInt(6) + 1; } } class Player { private Dice dice; public Player(Dice dice) { this.dice = dice; } public int[] rollDice() { int[] diceValues = new int[6]; for (int i = 0; i < 6; i++) { diceValues[i] = dice.roll(); } return diceValues; } } class Game { private Player player; public Game(Player player) { this.player = player; } public void start() { int[] diceValues = player.rollDice(); // 根据点数组合进行判断奖励或者惩罚的逻辑 // ... } } public class Main { public static void main(String[] args) { Dice dice = new Dice(); Player player = new Player(dice); Game game = new Game(player); game.start(); } } ``` 这是一个简单的博饼小游戏的Java实现示例。在实际的游戏中,你可以根据需求进行更加详细和复杂的设计和实现。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值