diff --git a/pom.xml b/pom.xml index 8c7c7c8..8b2aa2d 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,13 @@ + + + + com.google.guava + guava + 33.0.0-jre + org.projectlombok diff --git a/src/main/java/cc/niushuai/demo/designpattern/creatormodel/prototype/_01/QuestionService.java b/src/main/java/cc/niushuai/demo/designpattern/creatormodel/prototype/_01/QuestionService.java new file mode 100644 index 0000000..e8cad5a --- /dev/null +++ b/src/main/java/cc/niushuai/demo/designpattern/creatormodel/prototype/_01/QuestionService.java @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2023 niushuai233 niushuai.cc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cc.niushuai.demo.designpattern.creatormodel.prototype._01; + +import cc.niushuai.demo.designpattern.creatormodel.prototype._01.entity.*; +import cn.hutool.core.util.SerializeUtil; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 问题 + * + * @author niushuai233 + * @date 2023/12/22 9:36 + * @since 0.0.1 + */ +public class QuestionService { + + private static List questions = new ArrayList(); + + static { + initSelectQuestions(); + initJudgeQuestions(); + initAnswerQuestions(); + } + + private static void initSelectQuestions() { + + questions.add(createSelectQuestion("下列说法正确的是", + "JAVA程序中可以有多个main⽅法", + "JAVA程序的main⽅法必须写在类⾥⾯", + "JAVA程序的main⽅法中如果只有⼀条语句,可以不⽤{}(⼤括号)括起来", + "JAVA程序中类名必须与⽂件名⼀样", SelectAnswerEnum.B)); + questions.add(createSelectQuestion("表达式(11+3*8)/4%3的值是", "2", "1", "31", "0", SelectAnswerEnum.A)); + questions.add(createSelectQuestion("以下()不是合法的标识符", "void", "de$f", "x3x", "STRING", SelectAnswerEnum.A)); + questions.add(createSelectQuestion("1+1=?", "4", "2", "3", "1", SelectAnswerEnum.B)); + questions.add(createSelectQuestion("变量命名规范说法正确的是", + "变量不能以数字作为开头", + "A和a在java中是同⼀个变量", + "不同类型的变量,可以起相同的名字", + "变量由字⺟、下划线、数字、$符号随意组成", SelectAnswerEnum.D)); + } + + private static Question createSelectQuestion(String title, String optionA, String optionB, String optionC, String optionD, SelectAnswerEnum answer) { + Question question = new Question(); + question.setType(QuestionTypeEnum.SELECT); + question.setTitle(title); + ArrayList