1: Game Requirements
1. Randomly display a name with several photos (e.g. 3 photos). Choose the right photo.
2. Record the teacher's awareness of each student's probability p. And according to the probability of cognition, determine the frequency of the "guess" game in the middle school students.
Recognition probability P = exact number of recognition/(exact number of recognition + number of errors identified)
A) Principle 1: Students with high probability of cognition are relatively low in guessing the game.
b) Principle 2: Students with low probability of cognition. Guess the frequency of the game appears relatively high.
c) Principle 3: Students who know the probability of 100%. There is also the possibility of appearing.
D) Principle 4: Students who recognize probability 0% do not have to appear every time.
Please design an algorithm to implement the above principles.
3. To realize the function of attendance in the classroom, we can make attendance (set a proportion) according to the photograph and name to some students. such as attendance 30%,50%, etc.). Setup can design an algorithm. Similar to Goal 3, there is randomness, at the same time each student's attendance frequency is different (based on previous attendance experience).
2, the design description narrative:
This system for guessing the game and attendance system
This system was created using the Windows window interface design.
System features include:
1. Randomly draw 3 numbers from the student number you have set up. and randomly display the photos of the three students.
2. Select the selected student's information in the set text file.
2. Record the information of each guessing and the named information of each school number.
3, the current is the number of points to be guessed and the point of the information, as well as all the students are guessed and be point information.
4, each classmate up to three times, when the number of points more than 3 o'clock, display the warning form, prompting the user
Another roll call.
5. The total number of guesses or errors is more than 10. Display the form information, the game itself to end the initiative.
3. System specific Design--control selection:
1, ListBox1: Used to store and display all the students were point information.
2, Button1: is to start the name button. Used to control the random number of pumping. When the button is started, it becomes a stop button and the Stop button is pressed. Displays the number that was finally selected and shows the selected student photo.
3, Button2: is used to show the current is the point of the points of the students.
4, Button3: Is reset button, used to clear the ListBox1 data information.
5, Button4: is to show the ListBox1 records of all the students were point of the situation.
6, Timer1: Used to control the extraction process data in the blank place flashing.
7, Label1: Used to display the selected number and student information.
8, Label2: Used to display the total number of guesses.
9, Label3: Used to display the total number of guesses.
10, Label4: Used to show the game name "Guess."
11, Label5: Used to display the number, the total number of individual points, the total number of individuals guessed, the total number of individual guesses.
12, PictureBox1: Used to display the Arry1[i] array of pictures.
13, PictureBox2: Used to display the Arry2[i] array of pictures.
14, PictureBox3: Used to display the Arry3[i] array of pictures.
15, ImageList1: Used to store and display photos
4, the system specific design-code implementation:
1.timer1 Event: Controls the number of randomly selected numbers, extracting a random number for each array that stores the photo. And then randomly select a number in the selected number, as the guessed number, at the same time in the created file. corresponding reading number corresponding to the number of information.
private void Timer1_Tick (object sender, EventArgs e) {long Tick = DateTime.Now.Ticks; Random ran = new random ((int) (tick & 0xffffffffL) | (int) (tick >> 32)); for (int i = 0; i < Arry1. Length && i < Arry2. Length && i < Arry3. Length; i++) {Arry1[i] = ran. Next (0, imagelist1.images.count-1); Arry2[i] = ran. Next (0, imagelist1.images.count-1); Arry3[i] = ran. Next (0, imagelist1.images.count-1); int[] ary = new Int[3] {arry1[i], arry2[i], arry3[i]}; d = R.next (0, 2); x = Ary[d]; num = Ary[d]. ToString (); p = (double) c1[x]/(C1[x] + c2[x]); String[] line = File.ReadAllLines (@ "C:\users\administrator\desktop\c#\a.txt", Unicodeencoding.getencoding ("GB2312" )); Label1. Text = "number" + ary[d]. ToString () + "," + "Student Information" + line[ary[d]; } }
2.button1 event: Start to guess the button. Used to control the execution of the timer1, the display of three images and the information inside the ListBox1, as well as warning alerts
private void Button1_Click (object sender, EventArgs e) {int[] ary = new Int[3] {arry1[i], arry2[i], Arry3[i]}; d = R.next (0, 3); First_click =!first_click; if (!first_click) {timer1. Start (); Button1. Text = "Stop"; } else {timer1. Stop (); Button1. Text = "Start"; New System.Drawing.Size (30, 30); pictureBox1.Image = Imagelist1.images[arry1[i]]; Picturebox2.image = Imagelist1.images[arry2[i]]; Picturebox3.image = Imagelist1.images[arry3[i]]; c[x]++; if (C[x] > 3) {MessageBox.Show ("Warning: The classmate has been named more than three times, please call again"); Timer1. Start (); Button1. Text = "Stop"; } this.listBox1.Items.Add (num + "" + c[x]+ "" +count+ "" +count1); } }
3.picturebox1 event: A click on the picture event, infer whether the picture is corresponding to the student information, and calculate the total number of guesses or guesses and the total number of guesses or guesses and the tips to guess the right or wrong and the end of the game or pass. (And so on PictureBox2 event, PictureBox3 event)
private void PictureBox1_Click (object sender, EventArgs e) {int[] ary = new Int[3] {arry1[i], arry2[i ], Arry3[i]}; d = R.next (0, 2); if (arry1[i] = = x) {MessageBox.Show ("master, Congratulations, correct"); count++; c1[x]++; Label2. Text = "Guess the total number of times" + count; THIS.LISTBOX1.ITEMS.ADD (num + "+ c[x] +" "+ c1[x] +" "+ c2[x]); while (count==10) {MessageBox.Show ("Master, congratulations on your passing the game"); }} else {Messagebo X.show ("Master, wrong Oh, keep trying"); count1++; c2[x]++; Label3. Text = "Total number of guesses" + count1; THIS.LISTBOX1.ITEMS.ADD (num + "+ c[x] +" "+ c1[x] +" "+ c2[x]); while (count1 = = {MessageBox.Show ("master, very sorry, you did not pass the game"); } } }
4.button2 event: Used as "show this student information" shows the current classmate is a bit of information, used as the attendance function
private void Button2_Click (object sender, EventArgs e) { if (c[x] = = 3) { MessageBox.Show ("the classmate was named the third time") ; } if (c[x] = = 2) { MessageBox.Show ("the classmate was named the second time"); } if (c[x] = = 1) { MessageBox.Show ("the classmate was named for the first Time");} }
5. Button3 Event: Use as reset button to clear the information recorded in ListBox1
private void Button3_Click (object sender, EventArgs e) { this.listBox1.Items.Clear (); Result. Clear (); }
6. Button4 event: Used as "show all guessed and be point information" button, show all the students are currently guessed and the details of the point
private void Button4_Click (object sender, EventArgs e) { this.listBox1.Visible =!this.listbox1.visible; this.button3.Visible =!this.button3.visible; }
5. System implementation
1. Click to start the execution
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "align=" Middle "width=" "height=" >
2. Click the Start Name button to start the Call button to stop button:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center ">
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center ">
3. Click stop button: Shows the currently randomly selected three photos and student information
4. Click on the image. Jochi was right. Pop-up window display
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "width=" "height=" >
5, click on the picture, if the wrong guess, pop-up window display
6. If the number of random name extraction is more than three times. Pop-up window warning.
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "width=" "height=" >
7. If the picture is guessed incorrectly 10 times, the pop-up window displays. Guess the picture failed
8. If the picture guessed 10 times, pop-up window display, guess the picture success
9. Click on the button "The classmate is a bit of information", the pop-up window shows the information that the classmate was ordered
10. Click "All guessed and the number of points" and "reset" button, all the students are named in the list box, reset button is to clear the contents of the list box.
11. Student information in the text
6, Summary:
It took a lot of time to get this game off and on, about half a month. Of course, this is interspersed with a lot of assorted things, from a very long time to start to do, but for C # still too unfamiliar. This and I did not spend enough time to learn about it this semester, so when I started designing, my head was blank. Not a clue, just to find some inspiration from the contents of previous assignments. At first I took a lot of time in the way I chose the pictures, because I didn't have much contact with PictureBox. has not been able to use, this gave me a beginning to cause a lot of trouble, always stuck here in the back and forth, when the heart is particularly irritable, the Internet search information is a daze. Like a blind-headed fly. Impossible And then put it on hold for a few days. At this time the heart also calmed a lot, the head also starts slowly enters the topic. Start thinking seriously about the problem.
Because I'm reading a picture using a file stream function. Read the picture from the established path, but I found that I was unable to display the student information in the picture. So I changed the name of the picture to the natural number, the students in the information extracted into a TXT file in the face, with the Lable label control display, but so another problem, I can not ensure that the picture and the contents of the lable tag only a pair of corresponding, so this problem has troubled me a day, Later asked the roommate. After her hint, the selected three picture number into an array, in this array and then randomly select a random function, you can ensure that the picture and student information one by one corresponding. But I found there was no common denominator between the picture number and the student information that was changed to the natural serial number. So I could not even get up; After some thinking, I thought of the database, my idea is to put student information and picture number into the database. Reading from the database can have a common link point. So I changed the way I read the photos from the file stream to read from the database, but the problem came up very quickly. Because I am completely unfamiliar with the operation of the linked database. Although the previous work has tried to connect, but at that time because of computer software problems have not been connected, and then has been shelved this operation, after trying for a night, I gave up the idea of using the database. The problem seems to be back to the beginning, how to introduce talent and label information synchronization. Because no idea, I started to search all kinds of information on the Internet, and then I found a way to use ImageList. It uses the method of storing photos in an array, so that I can share this array, introduce each PictureBox inside, after many tests, changes. Finally, the photo coding and label synchronization display. At that time the mood is really excited to the extreme, finally finished the first step, sure enough is the beginning of everything difficult ah. The introduction of other things can be gradual, so I started to click on the image of the event, just write this part of the fact is not very thought, because I have been thinking is the click on the picture and the label information, the photo will be beating or flipping, the result of drilling niu Jiao Jian, has struggled how to let the photo after the click can move, Later, after the completion of the program, debugging only to know that only the number of photos and label information has one by one corresponding relationship, it can happen. So I wrote three identical programs in each of the PictureBox events, just to replace the conditional statements in the IF statement with the corresponding statements for each PictureBox, and then add the MessageBox, the total number of guesses/guesses, etc. in the IF statement, Through continuous changes, to join the attendance function and other steps. Finally finished the take shape of the guessing game, although the function of some other not intact, but I am quite comfortable. From the ignorant, to oneself to make a small game, in the process of harvesting the knowledge is very much, it is like an accumulation of wealth. 1.1 Points of accumulation. The lastHave must be others can not give, practice is the truth, in fact, I can do it.
The address of my Baidu network disk: Http://pan.baidu.com/s/1kTszg7H
C # Course Design---guessing games