88import org .junit .jupiter .api .Disabled ;
99import org .junit .jupiter .api .Test ;
1010
11- /**
12- * Finds the employee who has worked on the most projects.
13- *
14- * <p>If there are multiple employees with the same maximum number of projects, returns the employee
15- * with the longest total project duration in months. If there are still ties, returns any one of
16- * the tied employees.
17- *
18- * <p>Example:
19- *
20- * <pre>
21- * Input: [
22- * Employee(1, "John", [
23- * Project("Project A", 3),
24- * Project("Project B", 2)
25- * ]),
26- * Employee(2, "Alice", [
27- * Project("Project C", 4),
28- * Project("Project D", 1)
29- * ]),
30- * Employee(3, "Bob", [
31- * Project("Project E", 2),
32- * Project("Project F", 3),
33- * Project("Project G", 1)
34- * ])
35- * ]
36- * <br>
37- *
38- * Output: Employee(3, "Bob") (since Bob has worked on 3 projects with a total duration of 6 months)
39- * </pre>
40- */
11+ /// ### Finds the employee who has worked on the most projects.
12+ ///
13+ /// If there are multiple employees with the same maximum number of projects, returns the employee
14+ /// with the longest total project duration in months. If there are still ties, returns any one of
15+ /// the tied employees.
16+ ///
17+ /// ### Example:
18+ ///
19+ ///
20+ /// Input:
21+ /// ```json
22+ /// Employee(1, "John", [
23+ /// Project("Project A", 3),
24+ /// Project("Project B", 2)
25+ /// ]),
26+ /// Employee(2, "Alice", [
27+ /// Project("Project C", 4),
28+ /// Project("Project D", 1)
29+ /// ]),
30+ /// Employee(3, "Bob", [
31+ /// Project("Project E", 2),
32+ /// Project("Project F", 3),
33+ /// Project("Project G", 1)
34+ /// ])
35+ ///
36+ /// ```
37+ ///
38+ ///
39+ /// Output:
40+ /// ```json
41+ /// Employee(3, "Bob")
42+ /// ```
43+ /// Explanation: Since Bob has worked on 3 projects with a total duration of 6 months.
44+ ///
4145class G_EmployeesWhoWorkedOnMostProject {
46+ private static void addEmployees (
47+ ArrayList <Employee > employees ,
48+ Identity employee1 ,
49+ Collection <Project > employee1ProjectsHistory ,
50+ Identity employee2 ,
51+ Collection <Project > employee2ProjectsHistory ) {
52+ employees .add (
53+ new Employee (
54+ 1 , employee1 , 10000 , Department .ComputerScience , employee1ProjectsHistory , -1 ));
55+
56+ employees .add (
57+ new Employee (
58+ 2 , employee2 , 10000 , Department .ComputerScience , employee2ProjectsHistory , -1 ));
59+ }
60+
4261 @ Test
4362 @ Disabled ()
4463 public void employeeWorkedOnMostProject () {
@@ -61,19 +80,4 @@ public void employeeWorkedOnMostProject() {
6180
6281 Assertions .assertEquals (mySolution , yourSolution );
6382 }
64-
65- private static void addEmployees (
66- ArrayList <Employee > employees ,
67- Identity employee1 ,
68- Collection <Project > employee1ProjectsHistory ,
69- Identity employee2 ,
70- Collection <Project > employee2ProjectsHistory ) {
71- employees .add (
72- new Employee (
73- 1 , employee1 , 10000 , Department .ComputerScience , employee1ProjectsHistory , -1 ));
74-
75- employees .add (
76- new Employee (
77- 2 , employee2 , 10000 , Department .ComputerScience , employee2ProjectsHistory , -1 ));
78- }
7983}
0 commit comments