由于现今大学学生纵多,而相对老师较少,每个老师教的学生数目多。一学期下来老师不能够认识所有学生,这样不便于师生之间互动,以及教师因材施教。从而设计了这样一个软件,便于教师迅速认识学生姓名,为教学过程中师生之间良好的互动提供了便利。
开发猜猜看软件,以供教学人员迅速识别学生,方便根据不同的学生因材施教,而且也便于课堂师生互动。大大提高了老师的教学效率,从根本上讲是有利于老师教学和学生学习的。
一下是对猜猜看的详细介绍:
一、首先看一下程序运行的界面以及设计时的界面(分为两个类型)
1>、
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace 猜猜看
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int[] sumStudentPhoto = new int[56]; // 记录imagelist1的数组,照片出现的总数
String[] sumStudentNames = new String[56]; // 记录学生的名字
int m, n; // 记录两个错误名字选项的下标
int p1, p2; // 记录两个错误图片选项的下标
int t = 0; // 记录正确答案数组的下标
int x1, x2, x3; // 三个选项的参数
int[] num = new int[3]; // 获得三个选项的名字数组的下标
bool re_elect = new bool(); // 判断玩家是否重选了
float[] percent = new float[56]; // 认识率
int[] trueGuessNum = new int[56]; // 记录每张图片猜对的次数
int[] tp = new int[56]; // 控制高认识率学生出现的概率
int m0, m1, m2, m3, m4, m5; // 显示认识程度变量
private void Form1_Load(object sender, EventArgs e)
{
// 将名字存入数组
getStudentName();
}
// 开始游戏按钮
private void starGame_Click(object sender, EventArgs e)
{
randomStudent(); // 得到随机照片
cleanRadio123(); // 清空radiobutton选项
getThreeChecked(); // 得到三个选项的值
continueGame.Visible = false; // 隐藏继续游戏按钮
correctResult.Visible = false; // 隐藏查看正确答案按钮
this.label1.Text = "请选择答案";
re_elect = false; // 默认没有重选
label5.Text = "选择答案查看";
}
// 第一个选项按钮
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (re_elect == true) //检测是否重选
{
label1.Text = "只能选择一次";
}
else
{
if (num[x1] == t)
{
label1.Text = "正确";
trueGuessNum[num[x1]]++;
}
else
{
label1.Text = "错误";
}
}
continueGame.Visible = true; // 显示继续游戏按钮
correctResult.Visible = true; // 查看正确答案按钮
re_elect = true; // 打开检查重选
//计算认识率
percent[t] = (float)trueGuessNum[t] / (sumStudentPhoto[t] + 2);
label5.Text = percent[t].ToString("0.00%");
}
// 第二个选项按钮
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (re_elect == true)
{
label1.Text = "只能选择一次";
}
else
{
if (num[x2] == t)
{
label1.Text = "正确";
trueGuessNum[num[x2]]++;
}
else
{
label1.Text = "错误";
}
}
continueGame.Visible = true;
correctResult.Visible = true;
re_elect = true;
//计算认识率
percent[t] = (float)(trueGuessNum[t]) / (sumStudentPhoto[t] + 2);
label5.Text = percent[t].ToString("0.00%");
}
// 第三个选项按钮
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
if (re_elect == true)
{
label1.Text = "只能选择一次";
}
else
{
if (num[x3] == t)
{
label1.Text = "正确";
trueGuessNum[num[x3]]++;
}
else
{
label1.Text = "错误";
}
}
continueGame.Visible = true;
correctResult.Visible = true;
re_elect = true;
//计算认识率
percent[t] = (float)trueGuessNum[t] / (sumStudentPhoto[t] + 2);
label5.Text = percent[t].ToString("0.00%");
}
// 继续游戏按钮
private void continueGame_Click(object sender, EventArgs e)
{
this.label1.Text = "请选择答案";
this.label5.Text = "选择答案查看";
randomStudent();
getThreeChecked();
cleanRadio123();
re_elect = false;
continueGame.Visible = false;
correctResult.Visible = false;
re_elect = false;
}
// 随机产生三个选项
void getThreeChecked()
{
Random rn = new Random();
int p = randomStudentName1();
int q = randomStudentName2();
num[0] = t;
num[1] = p;
num[2] = q;
// 生成第一个选项
x1 = rn.Next(3);
radioButton1.Text = sumStudentNames[num[x1]].ToString();
// 生成第二个选项
x2 = rn.Next(3);
while (x2 == x1) // 排除重复
{
x2 = rn.Next(3);
}
radioButton2.Text = sumStudentNames[num[x2]].ToString();
// 生成第三个选项
x3 = rn.Next(3);
while (x3 == x1 || x3 == x2) // 排除重复
{
x3 = rn.Next(3);
}
radioButton3.Text = sumStudentNames[num[x3]].ToString();
}
// 清除三个选项的选择记录
void cleanRadio123()
{
radioButton1.Checked = false;
radioButton2.Checked = false;
radioButton3.Checked = false;
}
// 随机显示照片
void randomStudent()
{
bool boo = new bool();
boo = true;
Random ran = new Random();
t = ran.Next(56);
while (t == m || t == n)
{
t = ran.Next(56);
}
//imageList1.ImageSize = new Size(120, 120);
// 判断学生认识率是否大于 60%
while (boo)
{
if (percent[t] >= 0.6)
{
// 学生认识率高于99%时,出现的概率为原来的1/10
if (percent[t] >= 0.99)
{
m5++;
if (tp[t] == 9)
{
pictureBox1.Image = imageList1.Images[t];
sumStudentPhoto[t]++;
this.label3.Text = sumStudentPhoto[t].ToString();
tp[t] = 0;
boo = false;
}
else
{
tp[t]++;
t = ran.Next(56);
}
}
// 学生认识率在90%到99%之间,出现的概率为原来的1/5
if (percent[t] >= 0.9 && percent[t] < 0.99)
{
m4++;
if (tp[t] == 4)
{
pictureBox1.Image = imageList1.Images[t];
sumStudentPhoto[t]++;
this.label3.Text = sumStudentPhoto[t].ToString();
tp[t] = 0;
boo = false;
}
else
{
tp[t]++;
t = ran.Next(56);
}
}
// 学生认识率在80%到90%之间,出现的概率为原来的1/4
if (percent[t] >= 0.8 && percent[t] < 0.9)
{
m3++;
if (tp[t] == 3)
{
pictureBox1.Image = imageList1.Images[t];
sumStudentPhoto[t]++;
this.label3.Text = sumStudentPhoto[t].ToString();
tp[t] = 0;
boo = false;
}
else
{
tp[t]++;
t = ran.Next(56);
}
}
// 学生认识率在70%到80%之间,出现的概率为原来的1/3
if (percent[t] >= 0.7 && percent[t] < 0.8)
{
m2++;
if (tp[t] == 2)
{
pictureBox1.Image = imageList1.Images[t];
sumStudentPhoto[t]++;
this.label3.Text = sumStudentPhoto[t].ToString();
tp[t] = 0;
boo = false;
}
else
{
tp[t]++;
t = ran.Next(56);
}
}
// 学生认识率在60%到70%之间,出现的概率为原来的1/2
if (percent[t] >= 0.6 && percent[t] < 0.7)
{
m1++;
if (tp[t] == 1)
{
pictureBox1.Image = imageList1.Images[t];
sumStudentPhoto[t]++;
this.label3.Text = sumStudentPhoto[t].ToString();
tp[t] = 0;
boo = false;
}
else
{
tp[t]++;
t = ran.Next(56);
}
}
}
//学生认识率低于60%,出现的概率为1/125
else
{
pictureBox1.Image = imageList1.Images[t];
sumStudentPhoto[t]++;
boo = false;
}
}
this.label3.Text = sumStudentPhoto[t].ToString();
}
// 将名字存入sumStudentName[]
void getStudentName()
{
StreamReader reader = new StreamReader(@"E:\caicaikan\student_name\name.txt", Encoding.GetEncoding("gb2312"));
String line = reader.ReadLine();
int i = 0;
while (line != null)
{
sumStudentNames[i] = line;
i++;
line = reader.ReadLine();
}
reader.Close();
}
// 随机产生学生名字1(错误答案)
int randomStudentName1()
{
Random ran = new Random();
m = ran.Next(56);
while (m == n || m == t)
{
m = ran.Next(56);
}
return m;
}
// 随机产生学生名字2(错误答案)
int randomStudentName2()
{
Random ran = new Random();
n = ran.Next(56);
while (n == m || n == t)
{
n = ran.Next(56);
}
return n;
}
// 退出游戏按钮
private void exitGame_Click(object sender, EventArgs e)
{
this.Close();
}
// 查看正确答案按钮
private void correctResult_Click(object sender, EventArgs e)
{
if (num[x1] == t)
radioButton1.Checked = true;
if (num[x2] == t)
radioButton2.Checked = true;
if (num[x3] == t)
radioButton3.Checked = true;
label1.Text = "该学生的名字为:";
}
}
}
2>、
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;
namespace 猜猜看
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int[] sumStudentPhoto = new int[33]; // 记录imagelist1的数组,照片出现的总数
String[] sumStudentNames = new String[33]; // 记录学生姓名
int m, n; // 记录两个错误选项的下标
int t = 0; // 记录正确答案数组的下标
int x1, x2, x3; // 三个选项的参数
int[] num = new int[3]; // 获得三个选项的名字数组的下标
bool re_elect = new bool(); // 玩家是否重选
float[] percent = new float[33]; // 认识率
int[] trueGuessNum = new int[33]; // 记录每张照片猜对的次数
int[] tp = new int[33]; // 控制高认识率学生出现的概率
int n0, n1, n2, n3, n4, n5; // 显示认识程度变量
int p1, p2, t2=0;
// 对学生进行分类的数组
int[] zhuan_yeNum = new int[15];
int[] ban_jiNum = new int[16];
int[] ban_zhangNum = new int[19];
int[] xue_weiNum = new int[36];
int[] nan_shengNum = new int[28];
int[] nv_shengNum = new int[11];
private void Form1_Load(object sender, EventArgs e)
{
}
private void startGame_Click(object sender, EventArgs e)
{
getName();
getThreeChecked2(); // 获得三个选项
this.textBox1.Text = "请选择答案";
re_elect = false; // 默认没有重选
label4.Text = "选择答案查看";
}
void getStudentName()
{
try
{
StreamReader reader = new StreamReader(@"E:\caicaikan\student_name\name.txt", Encoding.GetEncoding("gb2312"));
String line = reader.ReadLine();
int i = 0;
while (line != null)
{
sumStudentNames[i] = line;
i++;
line = reader.ReadLine();
}
reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);//显示异常信息
}
}
// 随机得到一个名字
void getName()
{
bool boo = new bool();
boo = true;
Random ran = new Random();
t2 = ran.Next(33);
while (t2 == p1 || t == p2)
{
t2 = ran.Next(33);
}
// 判断学生认识率是否大于 60%
while (boo)
{
if (percent[t2] >= 0.6)
{
// 学生认识率高于99%时,出现的概率为原来的1/10
if (percent[t2] >= 0.99)
{
n5++;
if (tp[t2] == 9)
{
pictureBox1.Image = imageList1.Images[t2];
sumStudentPhoto[t2]++;
this.label3.Text = sumStudentPhoto[t2].ToString();
tp[t2] = 0;
boo = false;
}
else
{
tp[t2]++;
t2 = ran.Next(33);
}
}
// 学生认识率在90%到99%之间,出现的概率为原来的1/5
if (percent[t2] >= 0.9 && percent[t2] < 0.99)
{
n4++;
if (tp[t2] == 4)
{
pictureBox1.Image = imageList1.Images[t2];
sumStudentPhoto[t2]++;
this.label3.Text = sumStudentPhoto[t2].ToString();
tp[t2] = 0;
boo = false;
}
else
{
tp[t2]++;
t2 = ran.Next(33);
}
}
// 英雄认识率在80%到90%之间,出现的概率为原来的1/4
if (percent[t2] >= 0.8 && percent[t2] < 0.9)
{
n3++;
if (tp[t2] == 3)
{
pictureBox1.Image = imageList1.Images[t2];
sumStudentPhoto[t2]++;
this.label3.Text = sumStudentPhoto[t2].ToString();
tp[t2] = 0;
boo = false;
}
else
{
tp[t2]++;
t = ran.Next(33);
}
}
// 英雄认识率在70%到80%之间,出现的概率为原来的1/3
if (percent[t2] >= 0.7 && percent[t2] < 0.8)
{
n2++;
if (tp[t2] == 2)
{
pictureBox1.Image = imageList1.Images[t2];
sumStudentPhoto[t2]++;
this.label3.Text = sumStudentPhoto[t2].ToString();
tp[t2] = 0;
boo = false;
}
else
{
tp[t2]++;
t = ran.Next(33);
}
}
// 英雄认识率在60%到70%之间,出现的概率为原来的1/2
if (percent[t2] >= 0.6 && percent[t2] < 0.7)
{
n1++;
if (tp[t2] == 1)
{
pictureBox1.Image = imageList1.Images[t2];
sumStudentPhoto[t2]++;
this.label3.Text = sumStudentPhoto[t2].ToString();
tp[t2] = 0;
boo = false;
}
else
{
tp[t2]++;
t = ran.Next(33);
}
}
}
//英雄认识率低于60%,出现的概率为1/33
else
{
aRandomName.Text = sumStudentNames[t2];
sumStudentPhoto[t2]++;
boo = false;
}
}
this.label3.Text = sumStudentPhoto[t2].ToString();
}
// 获得一张随机图片1(干扰图片)
int randomPhoto1()
{
Random ran = new Random();
p1 = ran.Next(33);
while (p1 == p2 || p1 == t2)
{
p1 = ran.Next(33);
}
return p1;
}
// 获得一张随机图片2(干扰图片)
int randomPhoto2()
{
Random ran = new Random();
p2 = ran.Next(33);
while (p2 == p1 || p2 == t2)
{
p2 = ran.Next(33);
}
return p2;
}
// 随机显示三个选项
void getThreeChecked2()
{
Random rn = new Random();
int p = randomPhoto1();
int q = randomPhoto2();
num[0] = t2;
num[1] = p;
num[2] = q;
// 生成第一个选项
x1 = rn.Next(3);
pictureBox1.Image = imageList1.Images[num[x1]];
// 生成第二个选项
x2 = rn.Next(3);
while (x2 == x1) // 排除重复
{
x2 = rn.Next(3);
}
pictureBox2.Image = imageList1.Images[num[x2]];
// 生成第三个选项
x3 = rn.Next(3);
while (x3 == x1 || x3 == x2) // 排除重复
{
x3 = rn.Next(3);
}
pictureBox3.Image = imageList1.Images[num[x3]];
}
// 点击第一图片触发的事件
private void pictureBox1_Click(object sender, EventArgs e)
{
Graphics g = Graphics.FromHwnd(this.pictureBox1.Handle);
PaintEventArgs a = new PaintEventArgs(g, this.pictureBox1.ClientRectangle);
this.pictureBox1_Paint(this.pictureBox1, a);
g.Dispose();
delay(100);
pictureBox1.Image = imageList1.Images[num[x1]];
// 实现模式一选择答案功能
if (re_elect == true) //检测是否重选
{
textBox1.Text = "只能选择一次";
}
else
{
if (num[x1] == t)
{
textBox1.Text = "正确";
trueGuessNum[num[x1]]++;
}
else
{
textBox1.Text = "错误";
}
}
continueGame.Visible = true; // 显示继续游戏按钮
correctResult.Visible = true; // 查看正确答案按钮
re_elect = true; // 打开检查重选
//计算认识率
percent[t] = (float)trueGuessNum[t] / (sumStudentPhoto[t] + 2);
label4.Text = percent[t].ToString("0.00%");
}
// 点击第二张图片触发的事件
private void pictureBox2_Click(object sender, EventArgs e)
{
Graphics g = Graphics.FromHwnd(this.pictureBox2.Handle);
PaintEventArgs a = new PaintEventArgs(g, this.pictureBox2.ClientRectangle);
this.pictureBox2_Paint(this.pictureBox2, a);
g.Dispose();
delay(100);
pictureBox2.Image = imageList1.Images[num[x2]];
// 实现模式一选择答案功能
if (re_elect == true)
{
textBox1.Text = "只能选择一次";
}
else
{
if (num[x2] == t)
{
textBox1.Text = "正确";
trueGuessNum[num[x2]]++;
}
else
{
textBox1.Text = "错误";
}
}
continueGame.Visible = true;
correctResult.Visible = true;
re_elect = true;
//计算认识率
percent[t2] = (float)(trueGuessNum[t2]) / (sumStudentPhoto[t2] + 2);
label4.Text = percent[t2].ToString("0.00%");
}
// 点击第三张图片触发事件
private void pictureBox3_Click(object sender, EventArgs e)
{
Graphics g = Graphics.FromHwnd(this.pictureBox3.Handle);
PaintEventArgs a = new PaintEventArgs(g, this.pictureBox3.ClientRectangle);
this.pictureBox3_Paint(this.pictureBox3, a);
g.Dispose();
delay(100);
pictureBox3.Image = imageList1.Images[num[x3]];
if (re_elect == true)
{
textBox1.Text = "只能选择一次";
}
else
{
if (num[x3] == t)
{
textBox1.Text = "正确";
trueGuessNum[num[x3]]++;
}
else
{
textBox1.Text = "错误";
}
}
continueGame.Visible = true;
correctResult.Visible = true;
re_elect = true;
//计算认识率
percent[t] = (float)trueGuessNum[t] / (sumStudentPhoto[t] + 2);
label4.Text = percent[t].ToString("0.00%");
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
PictureBox p = (PictureBox)sender;
Pen pp = new Pen(Color.Khaki);
e.Graphics.DrawRectangle(pp, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.X + e.ClipRectangle.Width - 1, e.ClipRectangle.Y + e.ClipRectangle.Height - 1);
}
private void pictureBox2_Paint(object sender, PaintEventArgs e)
{
PictureBox p = (PictureBox)sender;
Pen pp = new Pen(Color.Khaki);
e.Graphics.DrawRectangle(pp, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.X + e.ClipRectangle.Width - 1, e.ClipRectangle.Y + e.ClipRectangle.Height - 1);
}
private void pictureBox3_Paint(object sender, PaintEventArgs e)
{
PictureBox p = (PictureBox)sender;
Pen pp = new Pen(Color.Khaki);
e.Graphics.DrawRectangle(pp, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.X + e.ClipRectangle.Width - 1, e.ClipRectangle.Y + e.ClipRectangle.Height - 1);
}
// 延时函数
private void delay(int iInterval)
{
DateTime now = DateTime.Now;
while (now.AddMilliseconds(iInterval) > DateTime.Now)
{
}
return;
}
}
}
以上为整个软件的简介,分为两个模式,猜猜看。