文章出處

public class fdgfg
{
    Vector<Expression> v;
    public fdgfg()
    {
        v = new Vector<Expression>();
    }
    public void produceExpression(int bit,char operator)
    {
        Expression temp = new Expression();
        temp.operator = operator;
        temp.a = (int)(Math.random() * Math.pow(10,bit));
        temp.b = (int)(Math.random() * Math.pow(10,bit));
        switch (operator) 
        {
            case '+': temp.c = temp.a + temp.b;break;
            case '-': temp.c = temp.a - temp.b;break;
            case '*': temp.c = temp.a * temp.b;break;
            case '/': temp.b = (temp.b == 0 ? //排除除法被除數為0的情況
                      temp.b = 1 +(int)(Math.random() * Math.pow(10,bit)-1): temp.b);
                      temp.c = temp.a / temp.b;break;
            default : core(temp,bit);//封裝混合運算測試
        }
 
        v.add(temp);
    }
    //混合運算的封裝測試
    public void core(Expression temp,int bit)
    {
        int rand  = (int)(Math.random()*4);
        switch(rand)
        {
            case 1: temp.c = temp.a + temp.b;temp.operator = '+';break;
            case 2: temp.c = temp.a - temp.b;temp.operator = '-';break;
            case 3: temp.c = temp.a * temp.b;temp.operator = '*';break;
            case 0: temp.b = (temp.b == 0 ? //排除除法被除數為0的情況
                    temp.b = 1 +(int)(Math.random() * Math.pow(10,bit)-1): temp.b);
                    temp.c = temp.a / temp.b;temp.operator = '/';break;
            default :
        }
    }


任務分配: 29羅凱旋 完成階段一的任務

伙伴 25廖灼燊 http://www.cnblogs.com/liaozhuoshen/p/4369428.html


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()