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

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

第一次冲刺阶段时间:11.17~11.27

本次程序是为了解决上次判断的问题,但是还是出现新的问题页面无法调整,需要进行改进

本次改进代码为:

import java.util.Random;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast; public class CalculatorActivity extends Activity {
private final Random num1=new Random();
private final Random num2=new Random();
private final Random r = new Random();
private char[] ch = {'+','-','*','/'}; //字符数组
private int index = r.nextInt(ch.length); //随机数,小于数组的长度数, 0~3
private char a=ch[index];
private TextView text1,text2,text3;
private EditText answer;
private Button surebutton;//确定按钮
private String c;
private String e;
private String b;
private int i1,i2,i3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calculator);
text1=(TextView)findViewById(R.id.textView1);//随机数字
text2=(TextView)findViewById(R.id.textView2);//运算符号
text3=(TextView)findViewById(R.id.textView3);//随机数字
answer=(EditText)findViewById(R.id.editText1);//运算结果
b=answer.getText().toString();//获取输入的数值
i1=Integer.valueOf(b);
c=String.valueOf(num1.nextInt(100));
i1=Integer.valueOf(c);
String d=String.valueOf(a);
e=String.valueOf(num2.nextInt(100));
i3=Integer.valueOf(e);
text1.setText(c);//随机数1-100
text2.setText(d);//随机运算符+,-,*,/
text3.setText(e);//随机数1-100
surebutton=(Button)findViewById(R.id.surebutton);//确定按钮
surebutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(index){
case 0:
{
if(i1==i2+i3)
Toast.makeText(CalculatorActivity.this, "正确"+b, Toast.LENGTH_SHORT).show();
else
Toast.makeText(CalculatorActivity.this, "错误"+b, Toast.LENGTH_SHORT).show();
break;
}
case 1:
{
if(i1==i2-i3)
Toast.makeText(CalculatorActivity.this, "正确"+b, Toast.LENGTH_SHORT).show();
else
Toast.makeText(CalculatorActivity.this, "错误"+b, Toast.LENGTH_SHORT).show();
break;
}
case 2:{
if(i1==i2*i3)
Toast.makeText(CalculatorActivity.this, "正确"+b, Toast.LENGTH_SHORT).show();
else
Toast.makeText(CalculatorActivity.this, "错误"+b, Toast.LENGTH_SHORT).show();
break;
}
case 3:
{
if(i3!=0){
if(i1==(i2/i3))
Toast.makeText(CalculatorActivity.this, "正确"+b, Toast.LENGTH_SHORT).show();
else
Toast.makeText(CalculatorActivity.this, "错误"+b, Toast.LENGTH_SHORT).show();
}
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.calculator, menu);
return true;
} }

失败截图,正在努力改进中!

最新文章

  1. IPv4头部结构
  2. git工作区、暂存区、版本库之间的关系
  3. dedecms代码研究三
  4. 简述C#中关键字var和dynamic的区别
  5. 济南学习 Day 3 T3 am
  6. ASP.NET MVC中的统一化自定义异常处理
  7. SpringMVC 常用注解
  8. dg error
  9. GridView.GridLines 属性
  10. Oracle截取某字段前后字符串
  11. MongoDB学习之路(二)
  12. 201521123099 《Java程序设计》 第10周学习总结
  13. js内置函数大全及基本使用方法(一)
  14. Javac的实现过程
  15. Python序列的一点用法
  16. Android中监控home键
  17. Linux 系统的安装 (最全收集)
  18. node中__dirname、__filename、process.cwd()、process.chdir()表示的路径
  19. 【Codeforces 1106E】 Lunar New Year and Red Envelopes
  20. LeetCode: Best Time to Buy and Sell Stock III 解题报告

热门文章

  1. 【js】实现继承的6种方法
  2. MD5+DES在C#.NET与Java/Android中的加解密使用
  3. Jenkins RCE(CVE-2018-1000861)
  4. apache-httpd工作模式
  5. mysql 压缩备份 压缩还原 命令
  6. UART串口通信
  7. 调用类java.lang.Math的成员方法"public static double random"运算下面表达式10000次,统计其中生成的整数0,1,2,.....20的个数分别是多少,并输出统计结果.(int)(Math.random()*20+0.5)
  8. HDU 3861 The King’s Problem(tarjan缩点+最小路径覆盖:sig-最大二分匹配数,经典题)
  9. python下安装lxml
  10. 调用聊天机器人 -小I机器人