小学四则运算APP 第一个冲刺阶段 第五天
团队成员:陈淑筠、杨家安、陈曦
团队选题:小学四则运算APP
第一次冲刺阶段时间:11.17~11.27
本次发布的是实现练习功能的成功
代码:
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);
final String c=String.valueOf(num1.nextInt(100));
i2=Integer.valueOf(c);
final String d=String.valueOf(a);
final String e=String.valueOf(num2.nextInt(100));
i3=Integer.valueOf(e);
while(i<0){
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++;
}
});
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent2=new Intent();
intent2.setClass(CalculatorActivity.this, resultActivity.class);
intent2.putExtra("panduan",puanduan[m] );
startActivity(intent2);
}
});
}
}
@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;
}
}
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;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
Bundle bundle=getIntent().getExtras();
Intent intent=getIntent();
final int i=bundle.getInt("shumu");
final String []puanduan=new String[i];
for(int g=0;g<i;g++){
puanduan[g]=intent.getStringExtra("panduan");
}
} @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;
} }
结果布局代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:text="@string/result"
android:textSize="30sp"/> <TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView2"
android:layout_toRightOf="@+id/textView1"
android:text="@string/panduan"
android:textSize="20sp" /> <TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_marginTop="14dp"
android:layout_toLeftOf="@+id/textView1"
android:text="@string/number"
android:textSize="20sp" /> <TextView
android:id="@+id/thenumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="20dp"
android:text="TextView" /> <TextView
android:id="@+id/sum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="44dp"
android:text="TextView"
android:textSize="20sp"/> <TextView
android:id="@+id/panduan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/thenumber"
android:layout_alignBottom="@+id/thenumber"
android:layout_toRightOf="@+id/textView1"
android:text="TextView" /> </RelativeLayout>
布局截图:

小学四则运算APP 第一个冲刺阶段 第五天的更多相关文章
- 小学四则运算APP 第一个冲刺阶段 第一天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 思考:初步了解小学四则运算数是在100以内的加减乘除,首先先从简单的地方入手,把最基础的算法功 ...
- 小学四则运算APP 第一个冲刺阶段 第六天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是重新排列整齐ResultActivity的布局代码activity_result. ...
- 小学四则运算APP 第一个冲刺阶段 第四天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布我们增加了CalculatorsActivity.java.YunsuanActivi ...
- 小学四则运算APP 第一个冲刺阶段 第三天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布是在与团队成员解决了昨天问题的基础上,再增加了几个界面,增加了一些功能,修改与增加的代 ...
- 小学四则运算APP 第一个冲刺 第八天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是还未完成的功能二(选择题): ChoiceActivity.java: packa ...
- 小学四则运算APP 第一个冲刺 第七天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是完成的功能一: 程序代码: MainActivity代码: import andr ...
- 小学四则运算APP 第一个冲刺 第二天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次程序是为了解决上次判断的问题,但是还是出现新的问题页面无法调整,需要进行改进 本次改进代码 ...
- 小学四则运算APP 第二个冲刺 第一天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第二次冲刺阶段时间:11.29~12.09 本次发布的是已完成的功能二(选择题): ChoiceActivity.java: packag ...
- 小学四则运算APP 第二次冲刺 第四天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第二次冲刺阶段时间:11.29~12.09 本次发布的是合并后的选择题功能界面的设置: ChoiceSet.java: package c ...
随机推荐
- http-server
http-server是基于node.js的一个简单.零配置的命令行web服务器,可以方便实现跨域资源请求, #全局安装: npm install http-server -g: 全局安装后就可以通过 ...
- numpy库数组拼接np.concatenate的用法
concatenate功能:数组拼接 函数定义:numpy.concatenate((a1, a2, ...), axis=0, out=None)
- 配置使用;yum安装slatstack的master,minion<at>centos6_x86_64
使用: ####################################### 配置: ####################################### 安装: 服务端安装: [ ...
- websocket python实现原理
""" pip install ws4py """ import json from ws4py.client.threadedclient ...
- CentOS中配置CDH版本的ZooKeeper
三台CentOS:Host0,Host1,Host2 在三台中分别安装zookeeper-server yum install zookeeper-server -y 修改zookeeper的配置文件 ...
- Oracle 表删除操作
删除表内容(dml):delete from 删除表结构(ddl):drop table xx 清空表(ddl):truncate table 清空整张表,不能回滚,不会产生大量日志文件: 表空间会得 ...
- 在ASP.NET非MVC环境中(WebForm中)构造MVC的URL参数,以及如何根据URL解析出匹配到MVC路由的Controller和Action
目前项目中有个需求,需要在WebForm中去构造MVC的URL信息,这里写了一个帮助类可以在ASP.NET非MVC环境中(WebForm中)构造MVC的URL信息,主要就是借助当前Http上下文去构造 ...
- 使用BAPI批量修改采购信息记录的税率
业务方面提出需求:由于国家税率从5月份开始16%更改为13%.要求开发一个批量修改采购信息记录税率的功能. 税代码就是税率,J2代表13% 这个需求在ME13里面就可以单个修改,所以可以用BDC,但后 ...
- Java转python第一天
1.python xx.py 2.字符串可以与数字相乘 str = "abc" msg = str*3 print(msg) # 结果:abcabcabc 3.换行用三个单引号 ' ...
- 20155301 Exp7 网络欺诈防范
20155301 Exp7 网络欺诈防范 1.基础问题回答 (1)通常在什么场景下容易受到DNS spoof攻击 (2)在日常生活工作中如何防范以上两攻击方法 2.实践过程记录 简单应用SET工具建立 ...