PROGRAMMING:Jmu-java-03 object oriented-06-inheritance and coverage comprehensive exercise - person, student, employee, company
Define person abstract class, student class, company class and Employee class.
**Properties of person class * *: ` string name, int age, Boolean gender`
**Methods of person class * *:
```
public Person(String name, int age, boolean gender);
public String toString(); // Returns a string in "name age gender" format
public boolean equals(Object obj);// If name, age and gender are all the same, return true; otherwise, return false
```
**Student * * class inherits from 'person', properties: ` string stuNo, string clazz`
**Method of student class:**
```
//It is recommended to use super to reuse the related parametric constructors of the person class
public Student(String name, int age, boolean gender, String stuNo, String clazz);
public String toString(); // Return to "s" tudent:person "ToString stuNo clazz" format
public boolean equals(Object obj);// First, call the equals method of the parent class. If it returns true, continue to compare stuNo and clazz.
```
**Company * * class attribute: ` string name`
**Company method:**
```
public Company(String name);
public String toString(); // Return name directly
public boolean equals(Object obj);// The same name returns true
```
**Employee * * class inherits from 'person', property:'company, company, double salary '`
**Employee class method:**
```
//It is recommended to use super to reuse the related parametric constructors of the person class
public Employee(String name, int age, boolean gender, double salary, Company company);
public String toString(); // Return to "e" mployee:person "ToString company salary"
public boolean equals(Object obj);// First, call the equals method of the parent class, if it returns true. Compare company with salary.
//When comparing the salary attribute, use decimalformat DF = new decimalformat ("#. #"); Keep 1 decimal place
```
**Important instructions for writing the equals method:**
1. Compare the company attribute of employee. Consider the case where the input is null. If the company is not null and the pass in is null, false is returned
2. When comparing all string character types, you should also consider 'null'.
#Tips
1. Collections.sort can be used for sorting
2. The equality method should be considered carefully
#Main method description
1. Create several student objects and employee objects.
Enter's', and then enter 'name age gender stuNo clazz' to create * * student object * *.
Enter 'e', and then enter 'name age gender salary company' to create * * employee object * *.
Then put the created object into 'list < person > personalist'. Enter other characters to end the creation.
**Creation Description: * * for string type, if it is' null ', the object will not be created, and the assignment will be' null '. For the company property, if it is null, the value will be assigned to 'null'. Otherwise, the corresponding company object will be created.
2. Implement * * sort the elements in the personalist in ascending order according to the name, and then sort the same names in ascending order according to the age * *. Tip: you can use 'comparable < person >' or 'comparator < person >'`
3. Accept the input. If the input is' exit ', then' return 'will exit the program. Otherwise, continue with the following steps.
4. Put the elements in personalist into stulist and emplist according to their types. Note: do not put two objects with the same content into the list (whether they are the same or not is determined by the results returned by equals).
5. Output the string 'stulist', and then output each object in the stulist.
6. Output the string 'emplist', and then output each object in the emplist.
`1-3 'is a test point
`4-6 'is a test point
###Input example:
```in
s zhang 23 false 001 net15
e wang 18 true 3000.51 IBM
s zhang 23 false 001 net15
e bo 25 true 5000.51 IBM
e bo 25 true 5000.52 IBM
e bo 18 true 5000.54 IBM
e tan 25 true 5000.56 IBM
e tan 25 true 5000.51 IBM
s wang 17 false 002 null
s wang 17 false 002 null
e hua 16 false 1000 null
s wang 17 false 002 net16
e hua 16 false 1000 null
e hua 18 false 1234 MicroSoft
!
continue
```
###Output example:
```out
E mployee:bo-18-true-IBM-5000.54
E mployee:bo-25-true-IBM-5000.51
E mployee:bo-25-true-IBM-5000.52
E mployee:hua-16-false-null-1000.0
E mployee:hua-16-false-null-1000.0
E mployee:hua-18-false-MicroSoft-1234.0
E mployee:tan-25-true-IBM-5000.56
E mployee:tan-25-true-IBM-5000.51
S tudent:wang-17-false-002-null
S tudent:wang-17-false-002-null
S tudent:wang-17-false-002-net16
E mployee:wang-18-true-IBM-3000.51
S tudent:zhang-23-false-001-net15
S tudent:zhang-23-false-001-net15
stuList
S tudent:wang-17-false-002-null
S tudent:wang-17-false-002-net16
S tudent:zhang-23-false-001-net15
empList
E mployee:bo-18-true-IBM-5000.54
E mployee:bo-25-true-IBM-5000.51
E mployee:hua-16-false-null-1000.0
E mployee:hua-18-false-MicroSoft-1234.0
E mployee:tan-25-true-IBM-5000.56
E mployee:tan-25-true-IBM-5000.51
E mployee:wang-18-true-IBM-3000.51
```
answer:If there is no answer, please comment
**Properties of person class * *: ` string name, int age, Boolean gender`
**Methods of person class * *:
```
public Person(String name, int age, boolean gender);
public String toString(); // Returns a string in "name age gender" format
public boolean equals(Object obj);// If name, age and gender are all the same, return true; otherwise, return false
```
**Student * * class inherits from 'person', properties: ` string stuNo, string clazz`
**Method of student class:**
```
//It is recommended to use super to reuse the related parametric constructors of the person class
public Student(String name, int age, boolean gender, String stuNo, String clazz);
public String toString(); // Return to "s" tudent:person "ToString stuNo clazz" format
public boolean equals(Object obj);// First, call the equals method of the parent class. If it returns true, continue to compare stuNo and clazz.
```
**Company * * class attribute: ` string name`
**Company method:**
```
public Company(String name);
public String toString(); // Return name directly
public boolean equals(Object obj);// The same name returns true
```
**Employee * * class inherits from 'person', property:'company, company, double salary '`
**Employee class method:**
```
//It is recommended to use super to reuse the related parametric constructors of the person class
public Employee(String name, int age, boolean gender, double salary, Company company);
public String toString(); // Return to "e" mployee:person "ToString company salary"
public boolean equals(Object obj);// First, call the equals method of the parent class, if it returns true. Compare company with salary.
//When comparing the salary attribute, use decimalformat DF = new decimalformat ("#. #"); Keep 1 decimal place
```
**Important instructions for writing the equals method:**
1. Compare the company attribute of employee. Consider the case where the input is null. If the company is not null and the pass in is null, false is returned
2. When comparing all string character types, you should also consider 'null'.
#Tips
1. Collections.sort can be used for sorting
2. The equality method should be considered carefully
#Main method description
1. Create several student objects and employee objects.
Enter's', and then enter 'name age gender stuNo clazz' to create * * student object * *.
Enter 'e', and then enter 'name age gender salary company' to create * * employee object * *.
Then put the created object into 'list < person > personalist'. Enter other characters to end the creation.
**Creation Description: * * for string type, if it is' null ', the object will not be created, and the assignment will be' null '. For the company property, if it is null, the value will be assigned to 'null'. Otherwise, the corresponding company object will be created.
2. Implement * * sort the elements in the personalist in ascending order according to the name, and then sort the same names in ascending order according to the age * *. Tip: you can use 'comparable < person >' or 'comparator < person >'`
3. Accept the input. If the input is' exit ', then' return 'will exit the program. Otherwise, continue with the following steps.
4. Put the elements in personalist into stulist and emplist according to their types. Note: do not put two objects with the same content into the list (whether they are the same or not is determined by the results returned by equals).
5. Output the string 'stulist', and then output each object in the stulist.
6. Output the string 'emplist', and then output each object in the emplist.
`1-3 'is a test point
`4-6 'is a test point
###Input example:
```in
s zhang 23 false 001 net15
e wang 18 true 3000.51 IBM
s zhang 23 false 001 net15
e bo 25 true 5000.51 IBM
e bo 25 true 5000.52 IBM
e bo 18 true 5000.54 IBM
e tan 25 true 5000.56 IBM
e tan 25 true 5000.51 IBM
s wang 17 false 002 null
s wang 17 false 002 null
e hua 16 false 1000 null
s wang 17 false 002 net16
e hua 16 false 1000 null
e hua 18 false 1234 MicroSoft
!
continue
```
###Output example:
```out
E mployee:bo-18-true-IBM-5000.54
E mployee:bo-25-true-IBM-5000.51
E mployee:bo-25-true-IBM-5000.52
E mployee:hua-16-false-null-1000.0
E mployee:hua-16-false-null-1000.0
E mployee:hua-18-false-MicroSoft-1234.0
E mployee:tan-25-true-IBM-5000.56
E mployee:tan-25-true-IBM-5000.51
S tudent:wang-17-false-002-null
S tudent:wang-17-false-002-null
S tudent:wang-17-false-002-net16
E mployee:wang-18-true-IBM-3000.51
S tudent:zhang-23-false-001-net15
S tudent:zhang-23-false-001-net15
stuList
S tudent:wang-17-false-002-null
S tudent:wang-17-false-002-net16
S tudent:zhang-23-false-001-net15
empList
E mployee:bo-18-true-IBM-5000.54
E mployee:bo-25-true-IBM-5000.51
E mployee:hua-16-false-null-1000.0
E mployee:hua-18-false-MicroSoft-1234.0
E mployee:tan-25-true-IBM-5000.56
E mployee:tan-25-true-IBM-5000.51
E mployee:wang-18-true-IBM-3000.51
```
answer:If there is no answer, please comment