资源简介
用到了java中方法的重写、重载、数组的相关操作,实现了教师、学生信息的录入、储存、人数统计、输出、删除等功能,缺失统计不同系不同班级学生成绩的功能,尽量有时间补上,程序很简单,仅仅是老师布置的实验题。代码较长,可以看看。

代码片段和文件信息
import java.util.*;
class Person1
{
protected String name;
protected int age;
protected static int count=0;
public Person1(String nameint age)
{
this.set(name);
this.set(age);
}
public Person1(String name)
{
this(name0);
}
public Person1()
{
this(“姓名未知“0);
}
public Person1(Person1 p1)
{
this(p1.namep1.age);
}
public void finalize()
{
System.out.println(“释放对象(“+this.toString()+“)“);
this.count--;
}
public void set(String name)
{
if(name==null||name==““)
this.name=“姓名未知“;
else
this.name=name;
}
public void set(int age)
{
if(age>0&&age<100)
this.age=age;
else
this.age=0;
}
public void set(String nameint age)
{
this.set(name);
this.set(age);
}
public void set(Person1 p1)
{
this.set(p1.name);
this.set(p1.age);
}
public String getName()
{
return this.name;
}
public int getAge()
{
return this.age;
}
public static void howMany()
{
System.out.println(“Person1.count=“+count+“ “);
}
public String belongClassName()
{
String str=““;
if(this instanceof Person1)
str=“Person1“;
return str;
}
public String toString()
{
return this.name+““+this.age+“岁“;
}
public void print()
{
this.howMany();
System.out.println(this.belongClassName()+“类(“+this.toString()+“)“);
}
public int olderThen(Person1 p2)
{
return this.age-p2.age;
}
public boolean equals(object obj)
{
if(this==obj)
{
return true;
}
if(obj instanceof Person1)
{
Person1 p1=(Person1)obj;
return this.name.equals(p1.name)&&this.age==p1.age;
}
return false;
}
}
class Teacher extends Person1
{
static String majorprof;
public static int[] count={0000000};
public Teacher(String nameint ageString majorString prof)
{
super(nameage);
this.major=major;
this.prof=prof;
count[0]++;
}
public void how_Many()
{
if(this.major.equals(“计算机“))count[1]++;
else if(this.major.equals(“数学“))count[2]++;
else if(this.major.equals(“英语“))count[3]++;
if(this.prof.equals(“讲师“))count[4]++;
else if(this.prof.equals(“副教授“))count[5]++;
else if(this.prof.equals(“教授“))count[6]++;
}
public void print()
{
System.out.println(“计算机专业教师有:“+count[1]+“人“);
System.out.println(“数学专业教师有:“+count[2]+“人“);
System.out.println(“英语专业教师有:“+count[3]+“人“);
System.out.println(“职称为讲师的教师有:“+count[4]+“人“);
System.out.println(“职称为副教授的教师有:“+count[5]+“人“);
System.out.println(“职称为教授的教师有:“+count[6]+“人“);
System.out.println(“教师总人数为:“+count[0]+“人“);
}
public String belongClassName()
{
String str=““;
if(this instanceof Teacher)
str=“Teacher“;
return str;
}
public void finalize()
{
System.out.println(“释放对象(“+this.toString()+“)“);
if(this.major.equals(“CS“))count[1]--;
else if(this.major.equals(“MA“))count[2]--;
else if(this.major.equals(“EN“))count[3]--;
if(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6541 2011-04-27 09:32 TestPer.java
----------- --------- ---------- ----- ----
6541 1
相关资源
- 基于java的在线考试系统-毕业设计
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
评论
共有 条评论