zoukankan      html  css  js  c++  java
  • 小学四则运算APP 第二阶段冲刺-第三天

    团队成员:陈淑筠、杨家安、陈曦

    团队选题:小学四则运算APP

    第二次冲刺阶段时间:11.29~12.09

    本次发布的是判断题的部分代码

    panduanset.java

    import com.example.calculator.R;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.RadioGroup;
    import android.widget.RadioGroup.OnCheckedChangeListener;
    import android.widget.TextView;
    
    
    public class panduanset extends Activity {
        private TextView panduannumber;
        private RadioGroup panduanRG;
        private int i,g;
        private Button panduanxunlian;
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_panduan_set);
            panduannumber=(TextView)findViewById(R.id.panduannumber);
            panduanRG=(RadioGroup)findViewById(R.id.panduangroup);
            panduanxunlian=(Button)findViewById(R.id.panduanxunlian);
            panduanRG.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                
                @Override
                public void onCheckedChanged(RadioGroup arg0, int arg1) {
                    // TODO Auto-generated method stub
                    i=arg1;
                }
            });
            panduanxunlian.setOnClickListener(new OnClickListener() {
                
                @Override
                public void onClick(View arg0) {
                    // TODO Auto-generated method stub
                    g=Integer.valueOf(panduannumber.getText().toString());
                    Intent intent=new Intent();
                    Bundle bundle=new Bundle();
                    bundle.putInt("panduansuanfa", i);
                    bundle.putInt("panduanshumu",g);
                    intent.setClass(panduanset.this,panduanActivity.class);
                    intent.putExtras(bundle);
                    startActivity(intent);
                }
            });
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
    }

    pandaunactivtity.java

    import java.util.Random;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.TextView;
    
    public class panduanActivity extends Activity{
        private Button next1;
        private Button result1;
        private TextView timu1;
        private int index,i;
        private int k,j,l,sum;
        private char a;
        private final Random num1=new Random();
        private final Random num2=new Random();
        private final Random r = new Random();
        private char[] ch = {'+','-','*','/'};
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_panduan);
            Bundle bundle=getIntent().getExtras();
            index=bundle.getInt("panduansuanfa");
            a=ch[index];
            i=bundle.getInt("panduanshumu");
            String c=String.valueOf(num1.nextInt(100));
            String b=String.valueOf(num2.nextInt(100));
            String g=String.valueOf(r.nextInt(3));
            k=Integer.valueOf(g);
            l=Integer.valueOf(c);
            j=Integer.valueOf(b);
            String d=String.valueOf(a);    
            switch(index){
            case 0:
                sum=l+j;
                break;
            case 1:
                sum=l-j;
                break;
            case 2:
                sum=l*j;
                break;
            case 4:
                sum=l/j;
                break;
            }
            switch(k){
            case 0:
                timu1.setText(c+d+b+"="+String.valueOf(sum));
                break;
            case 1:
                timu1.setText(c+d+b+"="+String.valueOf(sum+1));
                break;
            case 2:
                timu1.setText(c+d+b+"="+String.valueOf(sum+2));
                default:
                    break;
            }
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
    
    }
  • 相关阅读:
    Element-ui 的 slot 关系理解
    关于Delegate委托和Event事件的学习
    JavaScript 中 prototype 与 __proto__
    正向代理与反向代理的个人理解
    MVC和三层架构
    关于SqlDataAdapter的思考
    关于C#连接Oracle数据库
    关于VS配置环境
    富文本的实现
    博客
  • 原文地址:https://www.cnblogs.com/babybluecsj/p/5014540.html
Copyright © 2011-2022 走看看