设计一个person类java_定义一个Person类,含姓名、性别、年龄等字段;继承Person类设计...
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
package test2;
public class Person {
int age;
String name;
String gender;
public Person(int Age,String Name,String Gender) {
this.age=Age;
this.name=Name;
this.gender=Gender;
}
public String toString() {
return "姓名:"+name+"性别:"+gender+"年龄:"+age;
}
public static class Teacher extends Person{
static String title;
static String department;
public Teacher(String Title,String Department) {
super(Age,Name,Gender);
this.title=Title;
this.department=Department;
}
public String toString() {
return "姓名:"+name+"性别:"+gender+"年龄:"+age+"职称:"+title+"部门:"+department;
}
public static class Student extends Person{
int num;
int time;
String professional;
public Student(int Num,int Time,String Professional) {
super(Age,Name,Gender);
num=Num;
time=Time;
professional=Professional;
}
public String toString() {
return "姓名:"+name+"性别:"+gender+"年龄:"+age+"职称:"+title+"部门:"+department+"学号:"+num+"入学时间:"+time+"专业:"+professional;
}
public static void main(String args[]) {
Person s1=new Person("千寻","女",18);
System.out.println(s1);
Person s2=new Person("小嗝嗝",男,19,"驯龙高手","技术");
System.out.println(s2);
Person s3=new Person("波妞",女,17,"编程","技术部门","2017007","2017","通信");
System.out.println(s3);
}
}
}
【设计一个person类java_定义一个Person类,含姓名、性别、年龄等字段;继承Person类设计...】能否帮忙看一下,求指教
推荐阅读
- vue|一个基于vue3+vite+ts的完整项目
- AndroidStudio实现微信界面设计
- 一个故事看懂CPU的SIMD技术
- 数组的结构以及打印输出
- 【JavaScript高级程序设计】知识点小结 II
- c#|VS册程序设计C#---问卷调查系统
- 一个使用 Shell 脚本实现的 Docker
- 设计模式~单例模式
- Java|MyBatis Demo演示
- C++实现教职工信息管理系统课程设计