首页 > 其他 > 详细

2015430 加法阶段一的封装测试

时间:2015-04-30 17:46:23      阅读:163      评论:0      收藏:0      [点我收藏+]
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

2015430 加法阶段一的封装测试

原文:http://www.cnblogs.com/kasion/p/4469261.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!