1. 結對編程項目---四則運算 (10分)編程
基本功能要求:dom
1) 實現一個帶有用戶界面的四則運算。2) 生成的題目不能重複。3) 支持負數,例如-1,-1/2,-3‘4/5等。(達成)學習
須要支持的基本設定參數this
1) 題目的數量 2) 數值的範圍 3) 題目中最多幾個運算符(目前沒有達成) 4) 題目中或運算過程當中有無有分數(好比進行整數除法的時候不能除盡) 5) 題目中是否有乘除法 6) 題目中是否有括號 (目前沒有達成) 7) 題目中或運算過程當中有無負數編碼
學習感覺:spa
以前本身單獨進行做業的時候,會碰上不少的困難本身單獨解決不了,就會致使做業的上交延誤之類的問題,可是經過此次的兩人模式(咱們組是三我的進行)搭檔來進行編碼,我以爲在效率上提升了很多,而且對於做業的認真程度,對項目的理解更是深刻了不止一個層次。在進行的過程當中,雖然咱們也遇到了不少的問題,但經過與大神的交流還有本身查閱一些資料,也順利的解決了問題,可是還有一些題目的要求咱們沒有達到要求,以後會繼續跟進的。3d
結對隊友:於悅 http://www.cnblogs.com/yuyue1216/ 丁藝朔 http://www.cnblogs.com/dys123hahabalalacode
代碼:orm
form 1blog
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; namespace WindowsFormsApplication2 { public partial class Form1 : Form { Form2 form2; public Form1() { InitializeComponent(); form2 = new Form2(); } private void button0_Click(object sender, EventArgs e) { String name = this.textBox0.Text; // 獲取裏面的值 String password = this.textBox0.Text; if (name.Equals("admin") && password.Equals("admin")) // 判斷帳號密碼是否等於admin { MessageBox.Show("登陸成功"); form2.ShowDialog(); } else { MessageBox.Show("登陸失敗!"); } } } }
form 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; namespace WindowsFormsApplication2 { public partial class Form2 : Form { int n, r1,r2,ysf; Form3 form3; public Form2() { InitializeComponent(); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox1.Text = comboBox1.SelectedItem.ToString(); } private void button1_Click(object sender, EventArgs e) { Random ran = new Random(); n = Convert.ToInt32(comboBox1.Text.ToString()); r1 = int.Parse(textBox1.Text); r2 = int.Parse(textBox2.Text); if(comboBox2.SelectedItem.ToString() == "包含") { ysf = 4; } else { ysf = 2; } form3 = new Form3(n, r1, r2, ysf); form3.ShowDialog(); } private void button2_Click(object sender, EventArgs e) { this.Dispose(); } } }
form 3
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; namespace WindowsFormsApplication2 { public partial class Form3 : Form { char[] fuhao = { '+', '-', '*', '%' }; int n, r1, r2, ysf; public Form3(int n, int r1, int r2, int ysf) { InitializeComponent(); this.n = n; this.r1 = r1; this.r2 = r2; this.ysf = ysf; Form4 form4 = new Form4(); } private void button1_Click(object sender, EventArgs e) { listBox1.Items.Clear(); } private void button5_Click(object sender, EventArgs e) { Application.Exit(); } private void button3_Click(object sender, EventArgs e) { string t = ""; Random ran = new Random(); for (int i = 0; i < n; i++) { int num1 = ran.Next(r1, r2); int num2 = ran.Next(r1, r2); if(ysf == 2) { t = num1 + fuhao[ran.Next(2)].ToString() + num2 + "="; } else { t = num1 + fuhao[ran.Next(4)].ToString() + num2 + "="; } listBox1.Items.Add(t); } } private void button4_Click(object sender, EventArgs e) { this.Close(); } } }
程序截圖: