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个运算符。

    基本效果如上



  • 相关阅读:
    数据库系统原理
    Java并发编程详解读书笔记(一)
    Java基础之String
    Java基础之数据类型
    winform BackgroundWorker控件的用法
    汉子转拼音
    model验证(验证登录、注册...)
    Ajax.BeginForm 异步搜索
    Ajax.ActionLink 辅助方法实现局部刷新
    js 随笔
  • 原文地址:https://www.cnblogs.com/cxyliming/p/7630345.html
Copyright © 2011-2022 走看看