日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

完善

發布時間:2023/12/19 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 完善 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace 簡易運算 {class Pack //封裝{private int a;private int b;private string oper;private int anster = 0;public int OP{set{a = value;}get{return a;}}public int Pt{set{b = value;}get{return b;}}public string Oper{set{oper = value;}get{return oper;}}public int Aster{get{return anster;}}public int yusuan(){switch (oper){case "+":anster = a + b;break;case "-":if (a > b)anster = a - b;//else// throw new Exception("被減數不能小于零!");break;case "*":anster = a * b;break;case "/"://if (b == 0)//{// throw new Exception("被除數不能小于零!");//}//elseanster = a / b;break;}return anster;}public int fanhui(){return anster;}} } Form1代碼:
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 簡易運算 {public partial class Form1 : Form{public Form1(){InitializeComponent();}string path = "E:/";public static int count = 0;public static int t = 0;public static int right = 0;public static int sum;int n = 0;int m = 0;private void Form1_Load(object sender, EventArgs e){Class1 s = new Class1();s.text1();}private void button1_Click(object sender, EventArgs e){StreamWriter l1 = File.AppendText("1.txt");l1.WriteLine(text1.Text);l1.Close();StreamWriter l2 = File.AppendText("2.txt");l2.WriteLine(comboBox1.SelectedItem.ToString());l2.Close();StreamWriter l3 = File.AppendText("3.txt");l3.WriteLine(text2.Text);l3.Close();richTextBox1.Text += text1.Text + comboBox1.SelectedItem.ToString() + text2.Text + "\n";n++;text1.Text = "";text2.Text = "";savet.Enabled = true;opent.Enabled = true;text1.Focus();}private void savet_Click(object sender, EventArgs e){SaveFileDialog TxtSaveDialog = new SaveFileDialog();TxtSaveDialog.Filter = "RTF文件(*.RTF)|*.RTF";if (File.Exists(path)){this.richTextBox1.SaveFile(path, RichTextBoxStreamType.RichText);MessageBox.Show("保存成功", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);this.richTextBox1.Clear();savet.Enabled = false;}else{if (TxtSaveDialog.ShowDialog() == DialogResult.OK){this.richTextBox1.SaveFile(TxtSaveDialog.FileName, RichTextBoxStreamType.RichText);MessageBox.Show("保存成功", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);this.richTextBox1.Clear();savet.Enabled = false;}}}private void opent_Click(object sender, EventArgs e){OpenFileDialog TxTOpenDialog = new OpenFileDialog();TxTOpenDialog.Filter = "RTF文件(*.RTF)|*.RTF";if (TxTOpenDialog.ShowDialog() == DialogResult.OK){path = TxTOpenDialog.FileName;this.richTextBox1.LoadFile(TxTOpenDialog.FileName, RichTextBoxStreamType.RichText);savet.Enabled = false;opent.Enabled = false;MessageBox.Show("打開成功", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);}}private void button2_Click(object sender, EventArgs e){jishi.Text = t.ToString();timer1.Enabled = true;timer1.Interval = 1000;timer1.Start();string[] l1 = new string[100];l1 = File.ReadAllLines("1.txt");string[] l2 = new string[100];l2 = File.ReadAllLines("2.txt");string[] l3 = new string[100];l3 = File.ReadAllLines("3.txt");Box1.Text = l1[0];Box4.Text = l2[0];Box2.Text = l3[0];}private void Box3_KeyDown(object sender, KeyEventArgs e){//string s = Box4.Text;Pack operast = new Pack();operast.OP = int.Parse(Box1.Text);operast.Pt = int.Parse(Box2.Text);operast.Oper = Box4.Text;//switch (s)//{// case "+":// sum = int.Parse(Box1.Text) + int.Parse(Box2.Text);// break;// case "-":// sum = int.Parse(Box1.Text) - int.Parse(Box2.Text);// break;// case "*":// sum = int.Parse(Box1.Text) * int.Parse(Box2.Text);// break;// case "/":// sum = int.Parse(Box1.Text) / int.Parse(Box2.Text);// break;// default:// break;//}operast.yusuan();if (e.KeyCode == Keys.Enter){if (operast.Aster.ToString()==Box3.Text ){MessageBox.Show("回答正確哦!");count++;right++;}else{MessageBox.Show("回答錯誤哦!");count++;}m++;if (m < n){Box3.Clear();string[] ll = new string[100];ll = File.ReadAllLines("1.txt");Box1.Text = ll[m];string[] l2 = new string[100];l2 = File.ReadAllLines("2.txt");Box4.Text = l2[m];string[] l3 = new string[100];l3 = File.ReadAllLines("3.txt");Box2.Text = l3[m];}else{jishi.Enabled = false;Form2 frm = new Form2();frm.ShowDialog();}}}private void timer1_Tick(object sender, EventArgs e){t = t + 1;jishi.Text = t.ToString();}} } 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;namespace 簡易運算 {public partial class Form2 : Form{public Form2(){InitializeComponent();}private void Form2_Load(object sender, EventArgs e){textBox2.Text = Form1.count.ToString();textBox1.Text = Form1.right.ToString();textBox3.Text = ((Form1.right / (double)(Form1.count)) * 100).ToString() + "%";}private void label1_Click(object sender, EventArgs e){}} }

  

轉載于:https://www.cnblogs.com/harlem/p/4994781.html

總結

以上是生活随笔為你收集整理的完善的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。