Created
November 15, 2024 23:04
-
-
Save carloswm85/2d0798aa6de0cc450f96932ee1c4f5dc to your computer and use it in GitHub Desktop.
This is what the component should include. I'm not sure how to turn it into a component diagram though (not sure if even necessary either).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum RoleEnum | |
{ | |
Student, | |
Company | |
} | |
public interface ISearchEngine | |
{ | |
void Search(string query); // General search method | |
} | |
public class CompanySearchEngine : ISearchEngine | |
{ | |
public void Search(string query) | |
{ | |
// Implementation specific to companies | |
} | |
} | |
public class StudentSearchEngine : ISearchEngine | |
{ | |
public void Search(string query) | |
{ | |
// Implementation specific to students | |
} | |
} | |
public class SearchEngineFactory | |
{ | |
public static ISearchEngine GetSearchEngine(RoleEnum role) | |
{ | |
return role switch | |
{ | |
RoleEnum.Company => new CompanySearchEngine(), | |
RoleEnum.Student => new StudentSearchEngine(), | |
_ => throw new ArgumentException("Invalid role"), | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment