C # Xiaomi flash sale mini programs

Source: Internet
Author: User

2013-12-3

Xiaomi flash sale program

The activation code is 100 Xiaomi mobile phones. Three people buy the first mobile phone respectively. The network speed is 1 second. You can grab a mobile phone. The second is 5 seconds. The third is 10 seconds. Three people cannot grab the same mobile phone.

My thinking: ①: set three timer1 timer2 timer3 and set the attribute Interval to the corresponding network speed.

②: Three richTextBox1 are used to facilitate scroll bars when numbers are large.

③ Use a button to snap up and click three times, which means three people use the cycle.

④ The three labels show the number of mobile phones sold by three people.

Code thinking: define two global variables n1 sum (n1 = 1 indicates the number of 100 mobile phones starting from 1 sum = 100)

N1 must be in the if Loop

Define the global variable m to show the quantity of snapped up increase when sum

And so on... Remember: m is the timer1 variable timer2 and timer3 need to define two more

The complete code is as follows: a small program reads and plays in class

All code: using System;

Using System. Collections. Generic;

Using System. ComponentModel;

Using System. Data;

Using System. Drawing;

Using System. Linq;

Using System. Text;

Using System. Windows. Forms;

Namespace WindowsFormsApplication3

{

Public partial class Form3: Form

{

PublicForm3 ()

{

InitializeComponent ();

}

Intn1 = 1;

Int sum = 100;

Int m = 0;

Int m1 = 0;

Int m2 = 0;

Private voidtimereffectick (object sender, EventArgs e)

{

If (n1 <= sum)

{

RichTextBox1.AppendText (n1.ToString () + "\ n \ r ");

RichTextBox1.ScrollToCaret ();

N1 ++; m ++;

}

If (sum

{

Timer1.Stop ();

}

Label5.Text = "Total" + m;

}

Privatevoid timer2_Tick (objectsender, EventArgs e)

{

If (n1 <sum)

{

RichTextBox2.AppendText (n1.ToString () + "\ n \ r ");

RichTextBox2.ScrollToCaret ();

N1 ++; m1 ++;

}

If (sum <n1)

{

Timer2.Stop ();

}

Label6.Text = "Total:" + m1;

}

Privatevoid timer3_Tick (objectsender, EventArgs e)

{

If (n1 <sum)

{

RichTextBox3.AppendText (n1.ToString () + "\ n \ r ");

RichTextBox3.ScrollToCaret ();

N1 ++; m2 ++;

}

If (sum

{

Timer3.Stop ();

}

Label7.Text = "Total" + m2;

}

Int Num = 0;

Privatevoid button#click (objectsender, EventArgs e)

{

Num ++;

If (Num = 1)

{

Timer1.Start ();

}

Elseif (Num = 2)

{

Timer2.Start ();

}

Elseif (Num = 3)

{

Timer3.Start ();

}

Else

{

MessageBox. Show ("already °? You have bought o from the hacker and bought o from the hacker! ");

}

}

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.