获取题目和答案

package com.question.entity;

public class Answer {
	//答案ID
	private int answerId;
	//答案内容
	private String answerContent;
	//是否标准答案 1是,2否
	private int answerFlag;
	//答案序号
	private int answerNum;
	//答案code
	private String answerCode;
	//题目ID
	private int questionId;
	public int getAnswerId() {
		return answerId;
	}
	public void setAnswerId(int answerId) {
		this.answerId = answerId;
	}
	public String getAnswerContent() {
		return answerContent;
	}
	public void setAnswerContent(String answerContent) {
		this.answerContent = answerContent;
	}
	public int getAnswerFlag() {
		return answerFlag;
	}
	public void setAnswerFlag(int answerFlag) {
		this.answerFlag = answerFlag;
	}
	public int getAnswerNum() {
		return answerNum;
	}
	public void setAnswerNum(int answerNum) {
		this.answerNum = answerNum;
	}
	public int getQuestionId() {
		return questionId;
	}
	public void setQuestionId(int questionId) {
		this.questionId = questionId;
	}
	public String getAnswerCode() {
		return answerCode;
	}
	public void setAnswerCode(String answerCode) {
		this.answerCode = answerCode;
	}
	
}
package com.question.entity;

public class Question {
	//题目ID
	private int questionId;
	//题目内容
	private String questionContent;
	//题目类型 1单选,2多选
	private int questionType;
	
	public int getQuestionId() {
		return questionId;
	}
	public void setQuestionId(int questionId) {
		this.questionId = questionId;
	}
	public String getQuestionContent() {
		return questionContent;
	}
	public void setQuestionContent(String questionContent) {
		this.questionContent = questionContent;
	}
	public int getQuestionType() {
		return questionType;
	}
	public void setQuestionType(int questionType) {
		this.questionType = questionType;
	}
	
}
package com.question.test;

import java.util.ArrayList;
import java.util.List;

import com.question.entity.Answer;
import com.question.entity.Question;

public class TestQuestion {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//题目字符串
		String firstStr = "Servlet通常使用(C)表示响应信息是一个Excel文件的内容。";
		//答案字符串
		String secondStr = "(A)text/css(B)text/html(C)application/vnd.ms-excel(D)application/msword";
		//截取题目
		String firstString[] = null;
		//截取答案
		String secondString[] = null;
		//截取反括号的内容
		String thirdString[] = null;
		//题目中"("存在多少
		firstString = firstStr.split("(");
		int firstNum = firstString.length;
		//答案中"("存在多少
		secondString =  secondStr.split("(");
		int secondNum = secondString.length;
		String answerNo = "";//标准答案序号
		Question question = new  Question();
		StringBuffer strBuffer = new StringBuffer();
		for(int i=0;i answerList= new ArrayList();
		for(int i=0;i1) {
			question.setQuestionType(2);
		}else {
			question.setQuestionType(1);
		}
		System.out.println("问题内容:"+question.getQuestionContent()+"问题类型:"+(question.getQuestionType()==1?"单选":"多选"));
		for(Answer answer : answerList){
			System.out.println("答案序号:"+answer.getAnswerCode()+";答案内容"+answer.getAnswerContent()
			+";"+(answer.getAnswerFlag() == 1?"【是标准答案】":""));
		}
	}
	
}

后续公司去补齐落地和页面展示的内容,先把基本功能实现(针对单选)

转载于:https://my.oschina.net/u/3863864/blog/3037868

你可能感兴趣的:(获取题目和答案)