Java object-oriented design Question 1: java object-oriented design question
I feel that many new people do not know how to learn software development. I personally feel that it is too difficult to understand the software development knowledge because there are too few exercises. I must read the materials and practice them. Not to mention it as a newbie. Java's old man is also studying materials and practicing new technologies. Therefore, I organized and arranged a series of exercise questions, which were originally published on the technical help website. However, after all, the blog Park is bigger and I want to help new people learn from this topic.
1Ask the design department and personnel
Define the Department class;
Attribute: Department name.
Define personnel class:
Attribute: Name, employee ID, department, and phone number.
Method:
Constructor (Department );
Displays the details of the person. (Zhang San (U0001) Planning Department Tel: 1392645 ****)
Define company Class:
There are multiple departments and employees under the company, which are dynamic arrays;
Method:
Add employees to the company;
Search for employees by name;
Search for employees by phone;
Search for a department by department name;
Search for employees by name in the Department;
Search for employees by phone in the Department;
2Define departments with Complex Structures
Define Department classes in an object-oriented way.
The department requires a relationship between the upper and lower-level departments, for example: the root department is the headquarters, the second level department is Shijiazhuang branch, the third level department is the planning department, the fourth level department is the procurement center, and the fifth level department is the terminal equipment procurement department.
The upper and lower layers must support at least five layers.
Department attributes: Department name, higher-level department, department level (, 3), whether there is a lower-level department.
Department Method:
Constructor (Department name and superior department );
View the Department name;
View the department level;
Check whether a department has a lower-level department;
Check whether there is a subdepartment (query by name );
View the full name of a department (list the names of all its upper-level departments, separated by commas );
Originally published on the technology help website, it is indeed original.