软件开发环境与工具教程
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
软件开发环境与工具教程1实验目的
运行博饼小游戏
2实验环境
New Beans IDE 2.0
3方法描述
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace _1
{
class Program
{
private static void type(int[] a)
{
int[] num = new int[6];
for (int i = 0; i < 6; i++)
{
num[a[i] - 1]++;
}
if (num[0] == 6)
Console.WriteLine("遍地锦");
else if (num[3] == 6)
Console.WriteLine("满堂红");
else if (num[1] == 6 || num[2] == 6 || num[4] == 6 || num[5] == 6)
Console.WriteLine("云扑黑");
else if (num[3] == 5)
Console.WriteLine("五红");
else if (num[0] == 5 || num[1] == 5 || num[2] == 5 || num[4] == 5 || num[5] == 5) Console.WriteLine("五子");
else if (num[3] == 4 && num[0] == 2)
Console.WriteLine("状元插金花");
else if (num[3] == 4)
Console.WriteLine("状元");
else if (num[0] == 4 || num[1] == 4 || num[2] == 4 || num[4] == 4 || num[5] == 4) Console.WriteLine("四进");
else if (num[3] == 3)
Console.WriteLine("三红");
else if (num[3] == 2)
Console.WriteLine("二举");
else if (num[0] == 1 & num[1] == 1 && num[2] == 1 && num[4] == 1 && num[5] == 1)
Console.WriteLine("对堂");
else if (num[3] == 1)
Console.WriteLine("一秀");
else
Console.WriteLine("什么也没有");
}
static void Main(string[] args)
{
int[] a = new int[6];
int i;
char[,] number = new char[3, 33];
Console.WriteLine("是否开始博饼Y/N");
string c;
c = Console.ReadLine();
while (c == "y")
{
Console.WriteLine("您所投掷的筛子为:");
Random ran = new Random();
for (int o = 0; o < 3; o++)
for (int j = 0; j < 33; j++)
number[o, j] = ' ';
for (i = 0; i < 6; i++)
{
//a[i] = Convert.ToInt32(Console.ReadLine());
a[i] = ran.Next(6) + 1;
}
for (i = 0; i < 6; i++)
{
//test(i+1,a[i]);
switch (a[i])
{
case 1:
number[1, (i) * 6 + 1] = '●'; break;
case 2:
number[0, (i) * 6 + 1] = '●';
number[2, (i) * 6 + 1] = '●'; break;
case 3:
number[0, (i) * 6 + 1] = '●';
number[1, (i) * 6 + 1] = '●';
number[2, (i) * 6 + 1] = '●'; break;
case 4:
number[0, (i) * 6] = '●';
number[0, (i) * 6 + 2] = '●';
number[2, (i) * 6] = '●';
number[2, (i) * 6 + 2] = '●'; break;
case 5:
number[0, (i) * 6] = '●';
number[0, (i) * 6 + 2] = '●';
number[1, (i) * 6 + 1] = '●';
number[2, (i) * 6] = '●';
number[2, (i) * 6 + 2] = '●'; break;
case 6:
number[0, (i) * 6] = '●';
number[0, (i) * 6 + 2] = '●';
number[1, (i) * 6] = '●';
number[1, (i) * 6 + 2] = '●';
number[2, (i) * 6] = '●';
number[2, (i) * 6 + 2] = '●'; break;
}
}
for (i = 0; i < 3; i++)
{
for (int j = 0; j < 33; j++)
{
if (j % 6 == 0)
Console.BackgroundColor = ConsoleColor.White;
if (j % 6 == 3)
Console.ResetColor();
if ((number[0, (j / 6) * 6 + 1] != '●' && number[1, 6 * (j / 6)] != '●' && number[1, 6 * (j / 6) + 2] != '●' && number[2, 6 * (j / 6) + 1] != '●') && !(number[1, 6 * (j / 6) + 1] == '●' && number[0, 6 * (j / 6)] == '●'))
Console.ForegroundColor = ConsoleColor.Red;
else
Console.ForegroundColor = ConsoleColor.Black;
if (number[i, j] == '●')
Console.Write(number[i, j]);
else