- 9
- 0
- 约 4页
- 2017-06-08 发布于重庆
- 举报
新区-2012484055-张亨-软二
实验4-1
实验目的和要求
设计一个简单的Windows应用程序,在该程序中首先构造一个学生基本类,再分别构造小学生,中学生,大学生等派生类,当输入相关数据,单击不同的按钮时完成相关的功能;
2.实验代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace shiyan_4_1 public partial class Form1 : Form public Form1 InitializeComponent ; public abstract class Student protected string name; protected int age; public static int number; public Student string name, int age name; this.age age; number++; public string Name get return name; public abstract double Average ; public class Pupil : Student protected double chinese; protected double math; public Pupil string name, int age, double chinese, double math : base name, age this.chinese chinese; this.math math; public override double Average return chinese + math / 2; public class Jenior : Student protected double chinese; protected double math; protected double english; public Jenior string name, int age, double chinese, double math, double english : base name, age this.chinese chinese; this.math math; this.english english; public override double Average return chinese + math + english / 3; public class Senior : Student protected double xuanxiu; protected double bixiu; public Senior string name, int age, double xuanxiu, double bixiu : base name, age this.xuanxiu xuanxiu; this.bixiu bixiu; public override double Average return xuanxiu + bixiu / 2; private void button1_Click object sender, EventArgs e string a Convert.ToString textBox1.Text ; int b Convert.ToInt32 textBox2.Text ; double c Convert.ToInt32 textBox3.Text ; double d Convert.ToInt32 textBox4.Text ; Pupil p new Pupil a, b, c, d ; label6.Text 总人数: + Student.number + ,姓名: + p.Name + ,小学生,平均成绩为: + p.Average ; private void button2_Click object sender, EventArgs e string a Convert.ToString textBox1.Text ; int b Convert.ToInt32 textBox2.Text ; double c Convert.ToInt32 textBox3.Text ; double d Co
原创力文档

文档评论(0)