展开全部
要做出来不难我可以62616964757a686964616fe78988e69d8331333238653236帮你搞定他但是我不会管登陆页面因为个设涉及数据库的问题。。懒的搞。。还有我设计的页面可能不会太美观。。因为没时间去设计页面的问题。。。
我写了一个没有图片版的简易版本。。喜欢就拿去把。。。大多数功能已经实现其他需要调试的自己去调把。
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class testMath extends Frame {
public static final int W_WIDTH=800,W_HEIGHT=600;
public static final int X_LOCATION=0,Y_LOCATION=0;
Image offScreemImage = null;
Font myFont = new Font("Arial",Font.CENTER_BASELINE,14);
boolean started = false,resulted=false;
boolean [] answer = new boolean [10];
String [] questions = {
"10+10*10 =",
"i'm the quesiton 2",
"i'm the quesiton 3",
"i'm the quesiton 4",
"i'm the quesiton 5",
"i'm the quesiton 6",
"i'm the quesiton 7",
"i'm the quesiton 8",
"i'm the quesiton 9",
"i'm the quesiton 10"
};
int [] questionA = {110,2,3,4,5,6,7,8,9,10};
int questionNo=0;
int finalresult=0;
TextField answerArea;
public void lanchFram(){
this.setLocation(X_LOCATION,Y_LOCATION);
this.setSize(W_WIDTH, W_HEIGHT);
setVisible(true);
this.setTitle("数学测验");
this.setResizable(false);
this.setBackground(Color.white);
new Thread(new PaintThread()).start();
this.setFont(myFont);
//closing window's event
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent a) {
System.exit(0);
}
});
this.setLayout(null);
answerArea = new TextField(10);
Panel toolBar = new Panel();
Panel answerText = new Panel();
Label notify = new Label("输入你的答案:");
answerText.add(notify);
answerText.add(answerArea);
Button start=new Button("start");
Button next = new Button("next");
Button last = new Button("last");
Button result = new Button("result");
answerArea.addActionListener(new answers());
start.addActionListener(new started());
last.addActionListener(new lastQuestion());
next.addActionListener(new nextQuestion());
result.addActionListener(new results());
toolBar.add(start);
toolBar.add(next);
toolBar.add(last);
toolBar.add(result);
answerText.setBounds(300,350,200,60);
toolBar.setBounds(250,450, 300, 30);
add(answerText);
add(toolBar);
}
class answers implements ActionListener{
public void actionPerformed(ActionEvent e){
try{
if(questionA[questionNo]==Integer.parseInt(answerArea.getText())){
answer[questionNo]=true;
}
else{
answer[questionNo]=false;
}
answerArea.setText("");
}
catch(Exception x){
answerArea.setText("");
}
}
}
class started implements ActionListener{
public void actionPerformed(ActionEvent e){
started=true;
}
}
class nextQuestion implements ActionListener{
public void actionPerformed(ActionEvent e){
if(questionNo<9&&started&&!resulted){
questionNo++;
}
}
}
class lastQuestion implements ActionListener{
public void actionPerformed(ActionEvent e){
if(questionNo>0&&started&&!resulted){
questionNo--;
}
}
}
class results implements ActionListener{
public void actionPerformed(ActionEvent e){
if(started){
for(int i=0;i<10;i++){
if(answer[i]){
finalresult +=10;
}
}
resulted=true;
}
}
}
public static void main(String[] args) {
testMath a = new testMath();
a.lanchFram();
}
public void paint(Graphics g)
{
if(started){
g.drawString("Question:"+(questionNo+1)+" "+questions [questionNo], 300, 250);
}
if(resulted&&started){
int x=600,y=50;
for(int i = 0;i<10;i++){
g.drawString("Question"+i+": "+answer[i], x, y);
y+=30;
}
g.drawString("Final result:"+finalresult, x, y);
}
}
public void update(Graphics g) {
if(offScreemImage == null){
offScreemImage=this.createImage(W_WIDTH,W_HEIGHT);
}
Graphics gOffScreem = offScreemImage.getGraphics();
Color c = gOffScreem.getColor();
gOffScreem.setColor(Color.white);
gOffScreem.fillRect(0, 0, W_WIDTH,W_HEIGHT);
gOffScreem.setColor(c);
paint(gOffScreem);
g.drawImage(offScreemImage,0,0,null);
}
//set up the Frame update time
private class PaintThread implements Runnable{
public void run() {
while(true){
repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
已赞过
已踩过<
你对这个回答的评价是?
评论
收起