Write a test program that creates a Person , Student , Employee , Faculty , and Staff , and invok
来源:互联网 发布:rubymine linux 破解 编辑:程序博客网 时间:2024/06/06 03:31
Design a class named Person and its two subclasses named Student and Employee .Make Faculty and Staff subclasses of Employee . A person has a name,address, phonenumber, and email address. A student has a class status (freshman,sophomore,junior, or senior). Define the status as a constant. An employee has an office,salary, and date hired. A faculty member has office hours and a rank. A staffmember has a title. Override the toString method in each class to display the class name and the person’s name.
Write a test program that creates a Person , Student , Employee , Faculty , and Staff , and invokes their toString() methods.
public class Person {String name; String address; String telphone; public Person(String n,String a,String t){ name=n; address=a; telphone=t; } public String toString(){ return name+" Person"; }public void display(Person person){System.out.println(person);}}
public class Employee extends Person{String office;double salary;public Employee(String n,String a,String t,String o,double s){super(n, a, t);office = o;salary = s;}public String toString(){return name+"employee";}}
public class Student extends Person{final String class1="一年级";final String class2="二年级";final String class3="三年级"; final String class4="四年级"; public Student(String n,String a,String t) { super(n, a, t); } public String toString() { return name+" Student"; }}
public class Faculty extends Employee{int Level;public Faculty (String n,String a,String t,String o,double w,int level) {super(n, a, t, o, w);Level = Level;}public String toString(){return name+"Faculty";}}public class Staff extends Employee{String position;public Staff(String n,String a,String t,String o,double w,String p){super(n,a,t,o,w);position=p;}public String toString(){return name+"staff";}}public class Test {public static void main(String[] args) {Person p = new Person("网", "数据库的","2345678" );p.display(p);Student s = new Student("王宏","河南省漯河市","15839652309");s.display(s);Employee e = new Employee ("李四","河南省漯河市","0395112222","人事局",222.00);e.display(e);Faculty f = new Faculty("明明", "河北", "11232312", "帮手", 234,1);f.display(f);Staff sta = new Staff("红红","河南省周口市","13849472334","人事科",345.00,"副局长");sta.display(sta);}}
1 0
- Write a test program that creates a Person , Student , Employee , Faculty , and Staff , and invok
- Person Student Employee Faculty Staff 类
- Create an Apex class that calls a REST endpoint and write a test class
- [Script]Get Hierarchy of employee and supervisor hierarchy when a person id provided
- TPOT:a Python tool that automatically creates and optimizes machine learning pipelines
- Creates a pipe for reading and writing的例子程序
- ToXML. A function that creates XML
- Write a function that takes a string as input and returns the string reversed.
- How do I generate compatible train and test sets that get processed with a filter?
- [zz] Read and write a properties file
- Read and Write a /proc File
- 122.View the Exhibit for the structure of the STUDENT and FACULTY tables.
- Description of the default C and C++ libraries that a program will link with when built by using Vis
- Compiling and Running a Java Program with a Native Method
- A Simple C# And SQL Test
- Please enter the correct username and password for a staff account. Note tha
- Problem A: Person类与Student类的关系
- Problem A: Person类与Student类的关系
- 嵌入式C开发中非常常用的关键字
- Java 教程
- Java 集合 ConcurrentModificationException异常原因和解决方法
- 微信开发之JSSDK调用
- Win7 命令行 到 环境变量
- Write a test program that creates a Person , Student , Employee , Faculty , and Staff , and invok
- 第十一周 oj训练 牛顿迭代法求根
- 开发规范:CSS / Sass 开发规范
- Nginx优化
- Linux ALSA声卡驱动之五:移动设备中的ALSA(ASoC)
- Spring Boot 入门
- scala的Array操作
- JAVA 小白学习日记 - JAVA万年历
- CGLIB 和 JDK生成动态代理类的区别