1. 创建一个接口Person,包含两个属性PerName,PerAge,一个方法Sort(Person []p);
2. 创建Person接口的实现类Student,包含两个成员变量perName,perAge,实现Person接口中的两个属性,实现对该类中的两个成员变量进行存取;实现Sort()方法,实现对所有的学生按照年龄进行升序显示。
3. 创建Person接口的实现类Employee,包含两个成员变量perName,perAge,实现Person接口中的两个属性,实现对该类中的两个成员变量进行存取;添加empSalary成员变量,表示员工的工资,为该变量添加属性访问器;实现Sort()方法,对所有员工按照工资降序显示
在Main()方法中,创建长度为5的Student类的对象数组,分别从控制台接收数据给该数组赋值,显示出5个学生的信息,并调用Sort()方法,实现按照年龄排序的功能。再创建一个长度为5的Employee类的对象数组,完成同样功能。
2. 创建Person接口的实现类Student,包含两个成员变量perName,perAge,实现Person接口中的两个属性,实现对该类中的两个成员变量进行存取;实现Sort()方法,实现对所有的学生按照年龄进行升序显示。
3. 创建Person接口的实现类Employee,包含两个成员变量perName,perAge,实现Person接口中的两个属性,实现对该类中的两个成员变量进行存取;添加empSalary成员变量,表示员工的工资,为该变量添加属性访问器;实现Sort()方法,对所有员工按照工资降序显示
在Main()方法中,创建长度为5的Student类的对象数组,分别从控制台接收数据给该数组赋值,显示出5个学生的信息,并调用Sort()方法,实现按照年龄排序的功能。再创建一个长度为5的Employee类的对象数组,完成同样功能。
解决方案 »
- 关于fireBug调试jQuery脚本的问题
- if和while的混乱
- 网络编程中遇到的数据编码问题
- 调用本地非托管代码????
- DataGrid取数判断问题?
- C#开发的Winform程序,采用Net自带的打包工具打包,在客户端安装后,dll文件就存在客户端的机器上了.我如何才能不让客户端在别的项目中引用
- 明天要去一家软件公司面试,大家有什么建议吗?
- 请教
- 请问如何读入字节流的中文信息,还原出来啊?
- <<c#入门>> <<c#宝典>> <<programming c#>> 哪个是真英雄??
- 打开了新窗体,如何才能在不退出该窗体的情况下操作原来的窗体?
- 在TextBox 输入城市编号时光标移开 Label上就显示城市名
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 学生管理系统
{
public partial class Form22 : Form
{ //插入学生信息用到的数据
public string studnetno;
public string studentname;
public string sex;
public string ative;
public string address;
public string birth;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 学生管理系统
{
public partial class Form22 : Form
{ //插入学生信息用到的数据
public string studnetno;
public string studentname;
public string sex;
public string ative;
public string address;
public string birth;using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 学生管理系统
{
public partial class Form22 : Form
{ //插入学生信息用到的数据
public string studnetno;
public string studentname;
public string sex;
public string ative;
public string address;
public string birth;
////插入班级信息,确认按钮消息相应函数
private void button11_Click(object sender, EventArgs e)
{
//班级号不为空
if (textBox5.Text != "")
{
classno = textBox5.Text;
depart = textBox6.Text;
specical = textBox9.Text;
studyears = textBox8.Text;
entertime = dateTimePicker2.Value.ToString("yyyy-MM-dd");
Classinfo cla = new Classinfo();
cla.insert(classno, depart, specical, studyears, entertime);
textBox5.Text = "";
textBox6.Text = "";
textBox9.Text = "";
textBox8.Text = "";
// dateTimePicker2.Text = "";
}
else
{
MessageBox.Show("请填写班级号!");
}
}
…………
insert方法:
public void insert(string studentno, string studentname, string studentsex, string studentbirth, string studentnative, string studentaddress)
{
cmd.CommandText = "insert into student values(" + "'" + studentno + "','" + studentname + "','" + studentsex + "','" + studentbirth + "','" + studentnative + "','" + studentaddress + "')";
cmd.Connection = conn;
try
{
conn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("添加成功");
}
catch
{
MessageBox.Show("格式错误,,添加此信息失败!");
}
}
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 学生管理系统
{
public partial class Form22 : Form
{ //插入学生信息用到的数据
public string studnetno;
public string studentname;
public string sex;
public string ative;
public string address;
public string birth;
////插入班级信息,确认按钮消息相应函数
private void button11_Click(object sender, EventArgs e)
{
//班级号不为空
if (textBox5.Text != "")
{
classno = textBox5.Text;
depart = textBox6.Text;
specical = textBox9.Text;
studyears = textBox8.Text;
entertime = dateTimePicker2.Value.ToString("yyyy-MM-dd");
Classinfo cla = new Classinfo();
cla.insert(classno, depart, specical, studyears, entertime);
textBox5.Text = "";
textBox6.Text = "";
textBox9.Text = "";
textBox8.Text = "";
// dateTimePicker2.Text = "";
}
else
{
MessageBox.Show("请填写班级号!");
}
}
…………
//数据库连接
strCon = "server=localhost;database=zt;uid=sa;pwd=";
conn = new SqlConnection(strCon);
cmd = new SqlCommand();
insert方法:
public void insert(string studentno, string studentname, string studentsex, string studentbirth, string studentnative, string studentaddress)
{
cmd.CommandText = "insert into student values(" + "'" + studentno + "','" + studentname + "','" + studentsex + "','" + studentbirth + "','" + studentnative + "','" + studentaddress + "')";
cmd.Connection = conn;
try
{
conn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("添加成功");
}
catch
{
MessageBox.Show("格式错误,,添加此信息失败!");
}
}