zoukankan      html  css  js  c++  java
  • 《结对-四则运算生成器-开发过程》

    项目地址(码云):https://gitee.com/tdxm_bq/sizeyunsuan/

    使用Android stdio编辑器

    class Num {
    private int max = 100;
    private int min = 1;

    public int getMin() {
    return min;
    }

    public void setMin(int min) {
    this.min = min;
    }

    public int getMax() {
    return max;
    }

    public void setMax(int max) {
    this.max = max;
    }
    public int shu(){
    Random random = new Random();
    int s = random.nextInt(max)%(max-min+1) + min;
    return s;
    }
    public int fu(){
    Random random = new Random();
    int s = random.nextInt(4)%(4-1+1) + 1;
    return s;
    }
    }
    运算参数的随机生成部分单独创建了一个类来实现。
    if(f == 1){
    s1 = a.shu();
    s2 = a.shu();
    s3 = s1 + s2;
    timu[0] = s1 + "+" +s2;
    jieguo[0] = Double.toString(s3);
    }else if(f == 2){
    s1 = a.shu();
    s2 = a.shu();
    s3 = s1 - s2;
    timu[0] = s1 + "-" +s2;
    jieguo[0] = Double.toString(s3);
    }else if(f == 3){
    s1 = a.shu();
    s2 = a.shu();
    s3 = s1 * s2;
    timu[0] = s1 + "*" +s2;
    jieguo[0] = Double.toString(s3);
    }else if(f == 4){
    s1 = a.shu();
    s2 = a.shu();
    s3 = s1 / s2;
    timu[0] = s1 + "/" +s2;
    jieguo[0] = Double.toString(s3);
    }
    运算符用随机生成数字来实现1~4对应4个运算符。

    基本效果如上



  • 相关阅读:
    GDI+中发生一般性错误
    反复
    一些网址
    控制listview大图标之间的间距
    android 系统移植
    android 启动报错
    android init.rc 语法分析
    Linux下的管道编程技术dup函数和dup2函数
    为了防止打开的设备 被占用
    android 多媒体框架
  • 原文地址:https://www.cnblogs.com/cxyliming/p/7630345.html
Copyright © 2011-2022 走看看