Home > Back-end >  1, the experiment demands this experiment: in military training group as the background, comprehensi
1, the experiment demands this experiment: in military training group as the background, comprehensi

Time:09-28

1, experimental demands this experiment: to military training group as the background, comprehensive collection experience combined with the actual application mode and the general business of the list, 1 to 1. The business description: 1-1.1. This experiment is to school military training for the business background, according to gender group 1-1.2. In terms of routine training objects including grade or class of all student collective, 1-1.3. Due to differences between sexes, actual military training shall be carried out by gender group, 1-1.4. This experiment to simulate the military training for students from the perspective of technology application set grouping, 1-1.5. After the grouping, ordered by members of different gender groups according to the height, 1-1.6. The key concept of business: student collection, grouping and sorting, 1-2. To create an environment engineering and configuration: 1-2.1. Limit 1. Create the experiment project, named: SE_JAVA_EXP_E041; 1-2.2. Limit 2. Create a package, named: cn. Campsg. Java. Experiment; 1-2.3. Limit 3. Create a package, named: cn. Campsg. Java. Experiment. The entity; 1-3. Create a Trainee entity class: 1-3.1. Limit 1. In cn. Campsg. Java. The experiment, the entity in the package to create the Trainee entity class: Trainee, 1) Trainee class must implement Comparable interface, 1-3.2 for Trainee classes create properties, requirements are as follows: serial number access name attribute type attribute description 1 privatenamestring name 2 privatesexstring sex (female and male two) 3 privateheightfloat height: 1. For the above properties for the setter/getter methods; 1-3.3. Create 0 for Trainee class constructor, 1-3.4 for Trainee class implements the Comparable interface method, interface methods requirements are as follows: access method name method return value parameter publiccompareTointTrainee anthor other comparative object method this method is used to compare the two trainees height, 1) if the comparison is higher than the anthor object, return value greater than 0. 2) if the comparison is shorter than the anthor object, returns the value of less than zero; 3) if the comparison with the anthor as tall as a object, return the result is 0, 1-4. Create a member of the military training group business class: 1-4.1. Limit 1. In cn. Campsg. Java. The experiment, the entity in the package to create group business class: TraineesGroups, 1-4.2 for TraineesGroups classes create properties, requirements are as follows: serial number permission attribute name type attribute description 1 privatetrnlistlist & lt; Trainee> Said trained student list 2 privategroupsmap & lt; String, List Said trained students grouped collection description: the above attributes do not need to implement the corresponding setter/getter methods, 1-4.3. Create the trainee for TraineesGroups class initialization method, requirements are as follows: access method name method return value parameter publicinitTraineesVoidList TrnList said to grouping trainees method this method for grouping need trained student list of initialization, the method of business logic implementation and instructions are as follows: 1) the method to complete the attribute trnList initialization, parameter trnList can't be empty; 2) practice, after creating TraineesGroups objects must first of all, this method is called, 1-4.4 for TraineesGroups create approach to grouping children by gender, class requirements are as follows: access method name method return value parameter return value publicgroupTraineesMap No no method this method to initialize the trainees, grouped by gender, gender includes both male and female, the method of business logic implementation and relevant specification as follows: 1) if the trainee students members list is empty or not, no subsequent processing; 2) according to the gender create the corresponding training set grouping; 3) the students by gender were assigned to the corresponding group in the collection; 4) finish sorting the height of different groups of trainees, 1-5. According to simulation training group results: 1-5.1. Limit 1. In cn. Campsg. Java. The experiment in the package to create the main class: MainClass; 1-5.2. For the entrance to the main ways to create MainClass: the main; 1-5.3. In the main, creating a group object; 1-5.4. In the main, to create a set contains 10 trained students; 1-5.5. In the main, the application of grouping objects to complete the initialization of the training set; 1-5.6. In the main, the application of grouping objects are grouped and obtain the group; 1-5.7. In the main, the information of the Trainee in the console output per group, 2, and implementation approach 2-1. To create and configure the environment engineering, 2 - (2) create the Trainee entity class: 2-2.1 in cn. Campsg. Java. Experiment. The entity package creation award categories: Trainee. The comparison of 1) the class implements the Java interfaces: Comparable, 2-2.2 for Trainee class defines properties: 1) the Trainee's name: private String name; 2) the trainee gender: private String sex; 3) the trainee height: private float height; 4) for the above attributes, implement the corresponding setter/getter methods 2-2.3 for Trainee class to create the default 0 constructor, 2-2.4 for Trainee class implements the interface methods, its form is as follows: + prompt public int compareTo (Trainee anthor) {} this method carries on the comparison to the Trainee height, business logic implementation is as follows: 1) within the method to realize their own compared to the anthor object; 2), respectively, for its height and the anthor height; 3) use a Float comparison methods compare comparative height: Float.com pare said (their height, the anthor height); 4) returns comparison results, 2-3. Create a member of the military training group business class: 2-3.1 in cn. Campsg. Java. Experiment. The entity package created in the group business class TraineesGroups; 2-3.2. Create a private property for TraineesGroups classes: 1) trained student list: List TrnList=null; 2) after the grouping of grouped collection: Map Groups=null; 2-3.3. For TraineesGroups class to create a parameter initialization method, its form is as follows: + prompt public void initTrainees (List TrnList) {} 1) within the methods to complete the assignment of trained student list attribute: enclosing trnList=trnList; 2-3.4. For TraineesGroups class to create groupTrainees grouping method, its form is as follows: + prompt public Map GroupTrainees () {} (1) whether trnList is null or if there is a member, such as empty or no members direct return null; 2) create grouping objects and grouping for collection property assignment: groups=new HashMap (3) to create male and female two queue, List type and set to join groups; + prompt groups. Put (" male ", new ArrayList ()); Groups. Put (" female ", new ArrayList ()); 4) by a member of the loop to iterate through trnList object: first, get member object: Trainee Trainee=trnList. Get (I) secondly, judging the sex of the object properties: if members of the object of sex for male, add it to male the queue; If the sex of the members of the object for the female is added to the female in the queue, 5) using collection tools Collections classes for packet queue sorting: sort method Collections. The sort (groups. Get (sex)); 6) returns the grouping groups, 2-4. According to simulation training group results: 2-4.1. In the package cn. Campsg. Java. In the experiment to create business the main class: MainClass; 2-4.2. Defined in MainClass program entrance main methods: the main 2-4.3. In the main method, creating a group object: 1) TraineesGroups tg=new TraineesGroups (); 2-4.4. In the main method, create a student collection of 10 different trainees; 1) create a type contains Trainee only a collection of objects; 2) create 10 different trainees to join by means of cycle collection, 2-4.5. In the main method, call the tg initTrainees method were grouped initialization, 2-4.6. Define variables and call the tg groupTrainees grouping method for the assignment: Map Group=tg. GroupTrainees (); Out 2-4.7. According to the gender group, a group in the queue, and the queue member information output to the console, 3, 3-1. The verification and testing in project positioning the main class: MainClass 3 to 2. Right-click the MainClass class, select: Run the As - & gt; Java Application, 3 - (3) to run the program, to see if the output in line with expectations,

CodePudding user response:

refer to the original poster m0_47350613 response:
1, the demands of this experiment: in military training group as the background, comprehensive collection experience combined with the actual application mode and the general business of the list, 1 - (1) business: 1-1.1. This experiment is to school military training for the business background, according to gender group 1-1.2. In terms of routine training objects including grade or class of all student collective, 1-1.3. Due to differences between sexes, actual military training shall be carried out by gender group, 1-1.4. This experiment to simulate the military training for students from the perspective of technology application set grouping, 1-1.5. After the grouping, ordered by members of different gender groups according to the height, 1-1.6. The key concept of business: student collection, grouping and sorting, 1-2. To create an environment engineering and configuration: 1-2.1. Limit 1. Create the experiment project, named: SE_JAVA_EXP_E041; 1-2.2. Limit 2. Create a package, named: cn. Campsg. Java. Experiment; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull