Storage and improvement of the quiz

Source: Internet
Author: User

Form1 's 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 calculate{public partial class Form1:form        {public Form1 () {InitializeComponent ();            } private void Button2_Click (object sender, EventArgs e)//write title {string i = @ "one";            String II = @ "Tow";            String III = @ "three";            string f = @ "Onefu";            String F1 [email protected] "towfu";            Writ1 writ = new Writ1 (I,II,III,F,F1); Writ.            X = TextBox1.Text; Writ.            Y = TextBox2.Text; Writ.            Z = TextBox3.Text; Writ.            FF1 = Combobox1.text; Writ.            FF2 = Combobox2.text;            Writ.xie ();            Textbox1.clear ();            Textbox2.clear ();                  Textbox3.clear ();     private void Button3_Click (object sender, EventArgs e)//emptying the question bank   {String i = @ "one";            String II = @ "Tow";            String III = @ "three";            string f = @ "Onefu";            String f1 = @ "Towfu";            Writ1 writ = new Writ1 (i, II, III, F, F1); Writ.            X = TextBox1.Text; Writ.            Y = TextBox2.Text; Writ.            Z = TextBox3.Text; Writ.            FF1 = Combobox1.text; Writ.            FF2 = Combobox2.text;        Writ.qingkong ();            } private void Button1_Click (object sender, EventArgs e) {Form2 ford=new Form2 (); Ford.        ShowDialog (); }            }}

  COMPUTE Classes

Using system;using system.collections.generic;using system.linq;using system.text;namespace Calculate{class        Calculate1 {private int A;        private int B;        private int C;          private int rightanswer;       private string Operator1;        private string Operator2;              public int A {set {a = value;                      }} public int B {set {b = value;            }} public int C {set {c = value;            }} public int Rightanswer {get {return rightanswer;            }} public string Operator1 {set {Operator1 = value;       }} public string Operator2 {set {Operator2 = value;      }} public int correct () {string operat = Operator1 + Operator2;                    Switch (operat) {case "+ +": rightanswer=a+b+c;                Break                    Case "+-": rightanswer=a+b-c;                Break                    Case "+*": Rightanswer = a + b * C;                Break                    Case "+/": Rightanswer = a + b/c;                Break                    Case "-+": Rightanswer = a-B + C;                Break                    Case "--": Rightanswer = a-B-C;                Break                    Case "-*": Rightanswer = a-b * c;                Break                    Case "-/": Rightanswer = a-b/C;                Break                    Case "*+": Rightanswer = A * b + C;     Break           Case "* *": Rightanswer = A * B-C;                Break                    Case "* *": Rightanswer = A * b * c;                Break                    Case "* *": Rightanswer = A * B/C;                Break                    Case "/+": Rightanswer = A/b + C;                Break                    Case "/-": Rightanswer = A/b-C;                Break                    Case "/*": Rightanswer = A/b-C;                Break                    Case "//": Rightanswer = A/b/C;            Break        } return rightanswer; }    }}

 form2

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;using system.io;namespace Calculate{public partial CLA        SS Form2:form {public Form2 () {InitializeComponent ();        } private int i = 1;        Calculate1 CA = new Calculate1 ();        private void Form2_load (object sender, EventArgs e) {butt ();            private void Textbox4_keydown (object sender, KeyEventArgs e) {if (E.keycode = = Keys.enter) {ca. A = Int.                Parse (TextBox1.Text); Ca. B = Int.                Parse (TextBox2.Text); Ca. C = Int.                Parse (TextBox3.Text); Ca. Operator1 = Label1.                Text; Ca. Operator2 = Label2.                Text;                                Ca.correct (); if (Textbox4.text = = ca. Rightanswer.tostring ()) {MessAgebox.show ("answer is taken!")                "); } else {MessageBox.Show ("Answer Error!                ");                } textbox4.clear ();             Butt ();            }} private void Butt () {string[] line = File.ReadAllLines ("one"); if (I < line.                Length) {TextBox1.Text = Line[i];                String[] lines = File.ReadAllLines ("tow");                TextBox2.Text = Lines[i];                String[] Lin = File.ReadAllLines ("three");                TextBox3.Text = Lin[i];                string[] Linf = File.ReadAllLines ("Onefu"); Label1.               Text = Linf[i];               string[] Linf1 = File.ReadAllLines ("Towfu"); Label2.            Text = Linf1[i];                  } i++; }          }}

  Write class

Using system;using system.collections.generic;using system.linq;using system.text;using System.IO;namespace        Calculate{class Writ1 {private String A;        private string C;        private string D;        private string F1;                private string F2;        private string X;        private string y;        private string Z;        private string ff1;                     private string ff2;            Public Writ1 (String A, String C, String D, String F1, String F2) {a = A;            c = C;            D = D;            F1 = F1;        F2 = F2;            public string X {set {x = value;            }} public string Y {set {Y = value;            }} public string Z {set {Z = value; }} public string FF1 {set {                FF1 = value;            }} public string FF2 {set {ff2 = value;            }} public void Xie () {StreamWriter di=new StreamWriter (a,true); Di.            WriteLine (x); Di.            Close ();            StreamWriter er = new StreamWriter (c, true); Er.            WriteLine (y); Er.            Close ();            StreamWriter san = new StreamWriter (d, true); San.            WriteLine (z); San.            Close ();            StreamWriter fi = new StreamWriter (F1, True); Fi.            WriteLine (FF1); Fi.            Close ();            StreamWriter FII = new StreamWriter (F2, true); Fii.            WriteLine (FF2); Fii.                   Close ();            } public void Qingkong () {StreamWriter ddd = new StreamWriter (a); Ddd.            WriteLine (""); Ddd.              Close ();            StreamWriter AAA = new StreamWriter (c); Aaa.            WriteLine ("");Aaa.            Close ();            StreamWriter FFF = new StreamWriter (d); Fff.            WriteLine (""); Fff.            Close ();            StreamWriter fff1 = new StreamWriter (F1); Fff1.            WriteLine (""); Fff1.            Close ();            StreamWriter fff2 = new StreamWriter (F2); Fff2.            WriteLine (""); Fff2.        Close (); }                  }}

Storage and improvement of the quiz

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.