怎样用Java制作一个选择题

怎样用Java制作一个选择题?

package Work1;

public class TestSelect {
	public static void main(String[] args) {
		Question question=new Question(1, "()是拥有属性和方法的实体。", 5, "AB",
				new Select("A", "对象"), new Select("B", "类"), new Select("C", "方法"), 
				new Select("D", "类的实例"));
		System.out.println(question.toString());
	}

}

package Work1;

public class Question {
	int num;//序号
	String timu;//题目
    double sccore;//分值
    String answer;//答案
    Select seA;
    Select seB;
	Select seC;
    Select seD;
	public Question(int num, String timu, double sccore, String answer, Select se1, Select se2, Select se3,
			Select se4) {
		super();
		this.num = num;
		this.timu = timu;
		this.sccore = sccore;
		this.answer = answer;
		this.seA = se1;
		this.seB = se2;
		this.seC = se3;
		this.seD = se4;
	}
	@Override
	public String toString() {
		String tm=num + "、" + timu + "(" + sccore + "分)(答:" + answer + ")";
		tm+="\n"+seA;
		tm+="\n"+seB;
		tm+="\n"+seC;
		tm+="\n"+seD;
		return tm;
	}    
}

package Work1;

public class Select {
	String title;//选项abcd
	String content;//选项内容
	public Select(String title, String content) {
		super();
		this.title = title;
		this.content = content;
	}
	@Override
	public String toString() {
		return title+":"+content;
	}
}

实现效果
实现效果

  • 1
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值