Skip to content

Conversation

macborowy
Copy link

Challenge 3 Solution

Submitted by: @macborowy
Challenge: Challenge 3

Description

This PR contains my solution for Challenge 3.

Changes

  • Added solution file to challenge-3/submissions/macborowy/solution-template.go

Testing

  • Solution passes all test cases
  • Code follows Go best practices

Thank you for reviewing my submission! 🚀

Copy link

coderabbitai bot commented Oct 12, 2025

Walkthrough

Adds a standalone Go program implementing Employee and Manager types with methods to add, remove, search, and compute average salary over employees. main initializes a Manager, performs operations (add, remove, average, find), and prints outcomes.

Changes

Cohort / File(s) Summary
Employee management feature
challenge-3/submissions/macborowy/solution-template.go
Introduces Employee and Manager types; adds methods AddEmployee, RemoveEmployee, GetAverageSalary, FindEmployeeByID; implements a main function demonstrating usage and printing results.

Sequence Diagram(s)

sequenceDiagram
  participant U as main()
  participant M as Manager
  participant E as Employee

  U->>M: AddEmployee(Employee{ID:1,...})
  U->>M: AddEmployee(Employee{ID:2,...})
  U->>M: RemoveEmployee(id=1)
  U->>M: GetAverageSalary()
  M-->>U: float64 average
  U->>M: FindEmployeeByID(id=2)
  alt found
    M-->>U: *Employee (non-nil)
  else not found
    M-->>U: nil
  end
  U->>U: fmt.Println outputs results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title directly describes the addition of the solution for Challenge 3, which is the primary change introduced by this PR, and it accurately reflects the main content of the changeset without extraneous details.
Description Check ✅ Passed The description clearly outlines that this PR adds the solution for Challenge 3, specifies the file location, and confirms that tests pass and Go best practices are followed, making it directly relevant to the changeset.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
challenge-3/submissions/macborowy/solution-template.go (2)

21-29: Consider removing unnecessary parentheses.

The condition on line 24 has unnecessary parentheses around e.ID == id. Go convention is to omit parentheses around simple conditions unless needed for grouping.

Apply this diff to align with Go style conventions:

-		if (e.ID == id) {
+		if e.ID == id {

31-43: Consider removing unnecessary parentheses.

The condition on line 33 has unnecessary parentheses around len(m.Employees) == 0. Go convention is to omit parentheses around simple conditions.

Apply this diff to align with Go style conventions:

-	if (len(m.Employees) == 0) {
+	if len(m.Employees) == 0 {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2868df and 992b512.

📒 Files selected for processing (1)
  • challenge-3/submissions/macborowy/solution-template.go (1 hunks)
🔇 Additional comments (4)
challenge-3/submissions/macborowy/solution-template.go (4)

5-14: LGTM! Clean type definitions.

The Employee and Manager structs are well-defined with appropriate field types for the challenge requirements.


16-19: LGTM! Simple and correct implementation.

The AddEmployee method correctly uses a pointer receiver and the append operation is idiomatic Go.


45-55: Excellent implementation!

The method correctly uses for i := range and takes the address of the indexed element &m.Employees[i] rather than the loop variable. This is the proper pattern to return a pointer to a slice element and avoids common pitfalls with loop variable addresses.


57-69: LGTM! Good demonstration of functionality.

The main function clearly demonstrates all the Manager methods and provides a working example that validates the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant