ACCP7.0s2深入.net和c#第七章上机123

--上机1

public class instrument
    {
       public virtual string play() {
           return "";
       }
    }

public class piano:instrument
    {
       public override string play()
       {
           return "钢琴在演奏";
       }
    }

public class sachs:instrument
    {
       public override string play()
       {
           return "萨克斯在演奏";
       }
    }

public class SE
    {
       public string no { get; set; }
       public string name { get; set; }
       public string pop { get; set; }
       public SE() { }
       public SE(string no,string name,string pop) {
           this.no = no;
           this.name = name;
           this.pop = pop;
       }
    }

public class violin:instrument
    {
       public override string play()
       {
           return "小提琴在演奏";
       }
    }

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            init();
        }

        public void init() {
            List<SE> e = new List<SE>();
            SE a = new SE("001","王小明","100");
            SE b = new SE("002", "周新宇", "200");
            SE c = new SE("003", "盖茨", "300");
            e.Add(a);
            e.Add(b);
            e.Add(c);
            this.dataGridView1.DataSource = e;
        }
        

        private void 演奏ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 f = new Form2();
            DataGridViewRow dr = this.dataGridView1.CurrentRow;
            string s = dr.Cells[1].Value.ToString();
            f.title = s + "开始演奏";
            f.ShowDialog();
        }
    }

public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        public string title {
            set {
                this.groupBox1.Text = value;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SE em = new SE();
            instrument i = null;
            if (this.radioButton1.Checked) {
                i = new piano();
            }
            else if (this.radioButton2.Checked) {
                i = new violin();
            }
            else if (this.radioButton3.Checked) {
                i = new sachs();
            }
            MessageBox.Show(i.play());
        }
    }


--上机2 3

public class codejob:Job
    {
       public codejob(string type,string name,string desc):base(type,name,desc) { }
       public codejob() { }
       public int codinglines { get; set; }
       public int bugs { get; set; }
       public int workday { get; set; }
       public override void Execute()
       {
           Form2 f = new Form2();
           f.ShowDialog();
       }
       public override string Show(int a,int b,int c)
       {
           return "有效编码行数:" + codinglines + "遗留问题:" + bugs + "工作日" + workday;
       }
    }

public abstract class Job
    {
       public string type { get; set; }
       public string name { get; set; }
       public string description { get; set; }
       public Job(string type, string name, string description)
       {
           this.type = type;
           this.name = name;
           this.description = description;
       }
       public Job() { }
       public abstract void Execute();
       public abstract string Show(int a,int b,int c);
    }

public class testjob:Job
    {
       public testjob(string type,string name,string desc):base(type,name,desc) {}
       public testjob() { }
       public int casenum { get; set; }
       public int findbugs { get; set; }
       public int workday { get; set; }
       public override void Execute()
       {
           Form3 f = new Form3();
           f.ShowDialog();
       }
       public override string Show(int a,int b,int c)
       {
           return "测试用例个数:" + a + "发现bug数量:" + b + "所需工作日:" + c;
       }
    }

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            init();
        }
        public void init() {
            List<Job> j = new List<Job>();
            j.Add(new codejob("编码","编码","实现购物车模块"));
            j.Add(new codejob("编码", "编码基类", "完成项目基类模块"));
            j.Add(new testjob("测试", "压力测试", "测试项目已实现模块"));
            this.dataGridView1.DataSource = j;
        }
        codejob c = new codejob();
        testjob t = new testjob();
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void 执行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = this.dataGridView1.CurrentRow.Index;
            if (index < 2)
            {
                c.Execute();
            }
            else {
                t.Execute();
            }
        }

        private void 完成情况ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = this.dataGridView1.CurrentRow.Index;
            if (index < 2)
            {

                MessageBox.Show(c.Show(c.codinglines, c.bugs, c.workday));
            }
            else {
                
                MessageBox.Show(t.Show(t.casenum,t.findbugs,t.workday));
            }
            
        }
    }

public partial class Form2 : Form
    {
        codejob j = new codejob();
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            j.codinglines = Int32.Parse(this.textBox1.Text.ToString());
            j.bugs = Int32.Parse(this.textBox2.Text.ToString());
            j.workday = Int32.Parse(this.textBox3.Text.ToString());
            MessageBox.Show("提交成功!");
            this.Close();
        }
    }

 public partial class Form3 : Form
    {
        testjob t = new testjob();
        public Form3()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            t.casenum = Int32.Parse(this.textBox1.Text.ToString());
            t.findbugs = Int32.Parse(this.textBox1.Text.ToString());
            t.workday = Int32.Parse(this.textBox1.Text.ToString());
            MessageBox.Show("提交成功");
            this.Close();
        }
    }


  • 3
    点赞
  • 0
    评论
  • 5
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

参与评论 您还未登录,请先 登录 后发表或查看评论
©️2022 CSDN 皮肤主题:编程工作室 设计师:CSDN官方博客 返回首页

打赏作者

MaKube丶X

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值