小学四则运算APP 第一个冲刺 第七天
团队成员:陈淑筠、杨家安、陈曦
团队选题:小学四则运算APP
第一次冲刺阶段时间:11.17~11.27
本次发布的是完成的功能一:
程序代码:
MainActivity代码:
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button; public class MainActivity extends Activity { private Button xunlian; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
xunlian=(Button)findViewById(R.id.button1);
xunlian.setOnClickListener(new OnClickListener() { @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setClass(MainActivity.this, CalculatorSet.class);
startActivity(intent);
MainActivity.this.finish();
}
});
} @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;
} }
Calculatorset代码:
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button; public class MainActivity extends Activity { private Button xunlian; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
xunlian=(Button)findViewById(R.id.button1);
xunlian.setOnClickListener(new OnClickListener() { @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setClass(MainActivity.this, CalculatorSet.class);
startActivity(intent);
MainActivity.this.finish();
}
});
} @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;
} }
calculatoractivity代码:
import java.util.Random; import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
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 Button next;
private char[] ch = {'+','-','*','/'};//字符数组
//private int[]puanduan;
private int index; //随机数,小于数组的长度数, 0~3
private char a;
private TextView text1,text2,text3;
private EditText answer;
private Button surebutton;//确定按钮
private int i,m=0;
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);
Bundle bundle=getIntent().getExtras();
index=bundle.getInt("suanfa");
a=ch[index];
i=bundle.getInt("shumu");
final String[]puanduan=new String[i];
text1=(TextView)findViewById(R.id.textView1);//随机数字
text2=(TextView)findViewById(R.id.textView2);//运算符号
text3=(TextView)findViewById(R.id.textView3);//随机数字
answer=(EditText)findViewById(R.id.editText1);//运算结果
next=(Button)findViewById(R.id.next);
String c=String.valueOf(num1.nextInt(100));
i2=Integer.valueOf(c);
String d=String.valueOf(a);
String 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
final String b=answer.getText().toString();//获取输入的数值
i1=Integer.valueOf(b);
switch(index){
case 0:
{
if(i1==(i2+i3))
{
Toast.makeText(CalculatorActivity.this, "正确"+b, Toast.LENGTH_SHORT).show();
puanduan[m]="正确";
}
else
{
Toast.makeText(CalculatorActivity.this, "错误"+b, Toast.LENGTH_SHORT).show();
puanduan[m]="错误";
}
break;
}
case 1:
{
if(i1==(i2-i3))
{
Toast.makeText(CalculatorActivity.this, "正确"+b, Toast.LENGTH_SHORT).show();
puanduan[m]="正确";
}
else
{
Toast.makeText(CalculatorActivity.this, "错误"+b, Toast.LENGTH_SHORT).show();
puanduan[m]="错误";
}
break;
}
case 2:{
if(i1==(i2*i3))
{
Toast.makeText(CalculatorActivity.this, "正确"+b, Toast.LENGTH_SHORT).show();
puanduan[m]="正确";
}
else
{
Toast.makeText(CalculatorActivity.this, "错误"+b, Toast.LENGTH_SHORT).show();
puanduan[m]="错误";
}
break;
}
case 3:
{
if(i3!=0){
if(i1==(i2/i3))
{
Toast.makeText(CalculatorActivity.this, "正确"+b, Toast.LENGTH_SHORT).show();
puanduan[m]="正确";
}
else
{
Toast.makeText(CalculatorActivity.this, "错误"+b, Toast.LENGTH_SHORT).show();
puanduan[m]="错误";
}
}
break;
}
}
i--;
m++;
if(i==0){
Toast.makeText(CalculatorActivity.this,"已经到了了题目个数!",Toast.LENGTH_LONG ).show(); }
else{
String c=String.valueOf(num1.nextInt(100));
i2=Integer.valueOf(c);
String d=String.valueOf(a);
String e=String.valueOf(num2.nextInt(100));
i3=Integer.valueOf(e);
text1.setText(c);//随机数1-100
text2.setText(d);//随机运算符+,-,*,/
text3.setText(e);//随机数1-100
answer.setText(null);
}
}
});
next.setOnClickListener(new OnClickListener() { @Override
public void onClick(View arg0) {
if(i==0){
Intent intent=new Intent();
Bundle bundle2=new Bundle();
bundle2.putStringArray("panduan", puanduan);
bundle2.putInt("number", m);
intent.putExtras(bundle2);
intent.setClass(CalculatorActivity.this,resultActivity.class);
startActivity(intent);
CalculatorActivity.this.finish();
}
else
Toast.makeText(CalculatorActivity.this,"不到题目个数,请继续", Toast.LENGTH_LONG).show();
}
});
} @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;
} }
resultActivity代码:
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.TextView;
import android.widget.RadioGroup.OnCheckedChangeListener; public class resultActivity extends Activity {
private TextView number;
private TextView panduan;
//private TextView sum;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
Bundle bundle=getIntent().getExtras();
number=(TextView)findViewById(R.id.thenumber);
panduan=(TextView)findViewById(R.id.pan);
int i=bundle.getInt("number");
String []puanduan=bundle.getStringArray("panduan");
String aa="";
String aaa="";
for(int g=0;g<i;g++){
aa+=String.valueOf(g+1)+"\n";
aaa+=puanduan[g]+"\n";
number.setText(aa);
panduan.setText(aaa);;
}
} @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;
} }
运行结果:



小学四则运算APP 第一个冲刺 第七天的更多相关文章
- 小学四则运算APP 第一个冲刺阶段 第一天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 思考:初步了解小学四则运算数是在100以内的加减乘除,首先先从简单的地方入手,把最基础的算法功 ...
- 小学四则运算APP 第一个冲刺 第八天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是还未完成的功能二(选择题): ChoiceActivity.java: packa ...
- 小学四则运算APP 第一个冲刺阶段 第六天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是重新排列整齐ResultActivity的布局代码activity_result. ...
- 小学四则运算APP 第一个冲刺阶段 第五天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是实现练习功能的成功 代码: public class CalculatorActi ...
- 小学四则运算APP 第一个冲刺阶段 第四天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布我们增加了CalculatorsActivity.java.YunsuanActivi ...
- 小学四则运算APP 第一个冲刺阶段 第三天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布是在与团队成员解决了昨天问题的基础上,再增加了几个界面,增加了一些功能,修改与增加的代 ...
- 小学四则运算APP 第一阶段冲刺 第二天-补
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布已经解决上次问题,问题是写程序逻辑错误,问题已经修改!我们还增加两个模块的面板设置,如 ...
- 小学四则运算APP 第一个冲刺 第二天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次程序是为了解决上次判断的问题,但是还是出现新的问题页面无法调整,需要进行改进 本次改进代码 ...
- 小学四则运算APP 第一阶段冲刺
需求分析 1.相关系统分析员向用户初步了解需求,然后用word列出要开发的系统的大功能模块,每个大功能模块有哪些小功能模块,对于有些需求比较明确相关的界面时,在这一步里面可以初步定义好少量的界面.[1 ...
随机推荐
- [Tomcat]The JRE_HOME environment variable is not defined correctly
在tomcat的bin目录下,双击startup.bat,闪一下,就没了,后来仔细看了一下黑屏闪的内容如下: the JRE_HOME environment variable is not defi ...
- rowid快速分页解析
版权声明:个人随笔,实用你就COPY,看不懂不解释 https://blog.csdn.net/HelloCqk1/article/details/36628787 --分页第一步 获取数据物理地址 ...
- pku-2909 (欧拉筛)
题意:哥德巴赫猜想.问一个大于2的偶数能被几对素数对相加. 思路:欧拉筛,因为在n<215,在3万多,一个欧拉筛得时间差不多4*104, 那么筛出来的素数有4千多个,那么两两组合直接打表,时间复 ...
- QT 13 窗口屏幕设置大小与居中显示
<pre name="code" class="cpp">#include "mainwindow.h" #include &l ...
- CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境
准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...
- centos 7部署openvpn easy-rsa 3.0部署方法
yum install openvpn easy-rsa openssl-devel mkdir -p /etc/openvpn/easy-rsa/cp -p /usr/share/doc/easy- ...
- Mybatis集成(转)
文章转自http://blog.csdn.net/l454822901/article/details/51829653 什么是Mybatis MyBatis 本是apache的一个开源项目iBati ...
- TStack与IBM LinuxONE通过兼容性认证
近日,腾讯云TStack与IBM LinuxONE通过兼容性认证,通过腾讯云TStack,可实现便捷管理IBM LinuxONE服务器.这为腾讯和IBM在未来多方面的商业合作奠定了坚实基础,也为腾讯云 ...
- ES6中Object.assign() 方法
ES6中Object.assign() 方法 1. 对象合并Object.assign 方法用于对象的合并,将源对象(source)的所有可枚举属性,复制到目标对象上.如下代码演示: var targ ...
- 论文列表 for Action recognition
要读的论文: https://www.cnblogs.com/hizhaolei/p/10565405.html 骨架动作识别论文汇总 https://blog.csdn.net/bianxuewei ...