⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcdb.java

📁 背单词的软件
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   dccj.java
//coded by lengping
//all right reserved

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.*;
import java.io.PrintStream;
import java.util.LinkedList;
import java.util.Calendar;
import javax.swing.*;

public class Dcdb extends MyDialog
{

    JLabel lword;
    JLabel ltip;
    JLabel l1;
    JLabel l2;
    JLabel l3;
    JLabel l4;
    int icount;
    int iright;
    int ianswer;
    int ichoice;
    int iresult;
    boolean bwait;
    JLabel lall[];
    JLabel lpic[] = {
        new JLabel(""), new JLabel(""), new JLabel(""), new JLabel("")
    };
    static Icon icon1 = new ImageIcon("selected.gif");
    static Icon icon2 = new ImageIcon("bingle.gif");
    static Icon icon3 = new ImageIcon("right.gif");
    static Icon icon4 = new ImageIcon("wrong.gif");
    static Icon iconsymbol;
    LinkedList ll1;
    LinkedList ll2;
    Db db1;
    Studylog sl=new Studylog();
    ActionListener al=new ActionListener(){    	

	    public void actionPerformed(ActionEvent actionevent)
	    {
	        if(iright >= Person.wordspg)
	            end();
	        else
	            nextword();
	        timer.stop();
	        timer2.stop();
	        bwait = false;  	
	    }
	};
	    
    
    Timer timer;
    Timer timer2;
    KeyListener kl=new KeyListener(){
    public void keyPressed(KeyEvent keyevent)
    {
        //System.out.println("keyPressed" + keyevent.paramString() + keyevent.getKeyChar());
        switch(keyevent.getKeyCode())
        {
        default:
            break;

        case 40: // '('
            if(!bwait && ichoice != 3)
            {
                ichoice++;
                setChoice();
            }
            break;

        case 38: // '&'
            if(!bwait && ichoice != 0)
            {
                ichoice--;
                setChoice();
            }
            break;

        case 10: // '\n'
        case 32: // ' '
            postSelection();
            break;
        }
    }
    public void keyReleased(KeyEvent keyevent){}	
    public void keyTyped(KeyEvent keyevent){}	
    	
    };//end kl

    public Dcdb(JFrame jframe)
    {
        super(jframe, "单词测试", true);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent windowevent)
            {
            	timer.stop();
            	timer2.stop();
                dispose();
            }

        });
        
        lword = new JLabel("                    ");
        ltip = new JLabel("");
        l1 = new JLabel("                    ");
        l2 = new JLabel("                    ");
        l3 = new JLabel("                    ");
        l4 = new JLabel("                    ");
        bwait = false;
        lall = (new JLabel[] {
            l1, l2, l3, l4
        });
        ll1 = new LinkedList();
        ll2 = new LinkedList();
        db1 = new Db();
        al = new ActionListener() {

            public void actionPerformed(ActionEvent actionevent)
            {
                if(iright >= Person.wordspg)
                    end();
                else
                    nextword();
                timer.stop();
                timer2.stop();
                bwait = false;
            }

        };
        timer = new Timer(500, al);
        timer2 = new Timer(2000, al);
        kl = new KeyListener() {

            public void keyPressed(KeyEvent keyevent)
            {
                System.out.println("keyPressed" + keyevent.paramString() + keyevent.getKeyChar());
                switch(keyevent.getKeyCode())
                {
                default:
                    break;

                case 40: // '('
                    if(!bwait && ichoice != 3)
                    {
                        ichoice++;
                        setChoice();
                    }
                    break;

                case 38: // '&'
                    if(!bwait && ichoice != 0)
                    {
                        ichoice--;
                        setChoice();
                    }
                    break;

                case 10: // '\n'
                case 32: // ' '
                    postSelection();
                    break;
                }
            }

            public void keyReleased(KeyEvent keyevent)
            {
            }

            public void keyTyped(KeyEvent keyevent)
            {
            }

        };
        addKeyListener(kl);
        Container container = getContentPane();
        setSize(500, 400);
        container.setLayout(new GridLayout(5, 2));
        lword.setHorizontalAlignment(4);
        container.add(lword);
        ltip.setHorizontalAlignment(4);
        container.add(ltip);
        //phonetic symbol
        
        lpic[0].setHorizontalAlignment(4);
        lpic[1].setHorizontalAlignment(4);
        lpic[2].setHorizontalAlignment(4);
        lpic[3].setHorizontalAlignment(4);
        container.add(lpic[0]);
        container.add(l1);
        container.add(lpic[1]);
        container.add(l2);
        container.add(lpic[2]);
        container.add(l3);
        container.add(lpic[3]);
        container.add(l4);
        setCenter();
        init();
    }

    void init()
    {
        db1.setwordspg(Person.wordspg);
        db1.getGroup(ll1, Person.dcdbgroup);
        if(Person.dcdbgroup + 2 > Person.maxgroup)
            db1.getGroup(ll2, Person.dcdbgroup - 2);
        else
            db1.getGroup(ll2, Person.dcdbgroup + 2);
        setTitle("单词测试-第" + Person.dcdbgroup + "组");
        icount = -1;
        iright = 0;
        iresult=0;
        ltip.setText("开始了!        ");
        nextword();
    }

    void postSelection()
    {
        if(ichoice == ianswer)
        {
            iright++;
            Word word = (Word)ll1.get(icount);
            word.tag = 1;
            lpic[ianswer].setIcon(icon2);
            timer.start();
        } else
        {
            lpic[ianswer].setIcon(icon3);
            lpic[ichoice].setIcon(icon4);
            timer2.start();
        }
        bwait = true;
        ltip.setText("做对了" + iright + "个单词");
    }

    void nextword()
    {
        icount++;
        if(icount == Person.wordspg){
            icount = 0;
            iresult=iright;
            }
        for(Word word = (Word)ll1.get(icount); word.tag == 1; word = (Word)ll1.get(icount))
        {
            icount++;
            if(icount == Person.wordspg)
                icount = 0;
        }

        int i = (int)(Math.random() * (double)Person.wordspg);
        Word word1 = (Word)ll2.get(i);
        l1.setText(word1.zs);
        i = (int)(Math.random() * (double)Person.wordspg);
        word1 = (Word)ll2.get(i);
        l2.setText(word1.zs);
        i = (int)(Math.random() * (double)Person.wordspg);
        word1 = (Word)ll2.get(i);
        l3.setText(word1.zs);
        i = (int)(Math.random() * (double)Person.wordspg);
        word1 = (Word)ll2.get(i);
        l4.setText(word1.zs);
        
        //current word
        word1 = (Word)ll1.get(icount);
        lword.setText(word1.dc);
        ianswer = (int)(Math.random() * 4D);
        lall[ianswer].setText(word1.zs);
        //symbol
        iconsymbol=new ImageIcon(Symbol.getImage(word1.yb));
        ltip.setIcon(iconsymbol);
        ichoice = 0;
        setChoice();
    }

    void end()
    {
    	ltip.setText("你得了"+iresult*100/Person.wordspg+ "分!");    	
    	
        if(Person.dcdbgroup == Person.maxgroup)
        {
            JOptionPane.showMessageDialog(null, "恭喜你,已经背完了这本书!", "背单词", 1);
            dispose();
        }
        
        sl.personid=Person.personid;
		sl.function=2;
        sl.grade=iresult*100/Person.wordspg;
        sl.day=Calendar.getInstance();
        sl.book=Person.book;
        sl.wordgroup=Person.dcdbgroup;
        db1.addStudylog(sl);

        Object aobj[] = {
            "再做一次", "做下一组", "下次再做", "下次做下一组"
        };
        int i = JOptionPane.showOptionDialog(null, ":-)你已经通过测验了,要继续下一组吗?", "背单词", -1, 2, null, aobj, aobj[0]);
        if (i==1 || i==3){
        	Person.dcdbgroup++;
        	db1.updatePerson();        
        	}        	
        
        if(i == 0||i==1)
        {
            init();
        } else
        {
            dispose();
        }
    }

    void setChoice()
    {
        boolean flag = false;
        for(int i = 0; i < 4; i++)
            lpic[i].setIcon(null);

        lpic[ichoice].setIcon(icon1);
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -