You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
relentless/QuestionStrategyFactory.java

18 lines
562 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* 出题策略工厂类根据role返回对应策略
*/
public class QuestionStrategyFactory {
public static QuestionStrategy getStrategy(String role) {
switch (role) {
case "小学":
return new ElementaryQuestionStrategy();
case "初中":
return new MiddleSchoolQuestionStrategy();
case "高中":
return new HighSchoolQuestionStrategy();
default:
throw new IllegalArgumentException("未知的角色: " + role);
}
}
}