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

团队选题:小学四则运算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 第一个冲刺 第七天的更多相关文章

  1. 小学四则运算APP 第一个冲刺阶段 第一天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 思考:初步了解小学四则运算数是在100以内的加减乘除,首先先从简单的地方入手,把最基础的算法功 ...

  2. 小学四则运算APP 第一个冲刺 第八天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是还未完成的功能二(选择题): ChoiceActivity.java: packa ...

  3. 小学四则运算APP 第一个冲刺阶段 第六天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是重新排列整齐ResultActivity的布局代码activity_result. ...

  4. 小学四则运算APP 第一个冲刺阶段 第五天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是实现练习功能的成功 代码: public class CalculatorActi ...

  5. 小学四则运算APP 第一个冲刺阶段 第四天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布我们增加了CalculatorsActivity.java.YunsuanActivi ...

  6. 小学四则运算APP 第一个冲刺阶段 第三天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布是在与团队成员解决了昨天问题的基础上,再增加了几个界面,增加了一些功能,修改与增加的代 ...

  7. 小学四则运算APP 第一阶段冲刺 第二天-补

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布已经解决上次问题,问题是写程序逻辑错误,问题已经修改!我们还增加两个模块的面板设置,如 ...

  8. 小学四则运算APP 第一个冲刺 第二天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次程序是为了解决上次判断的问题,但是还是出现新的问题页面无法调整,需要进行改进 本次改进代码 ...

  9. 小学四则运算APP 第一阶段冲刺

    需求分析 1.相关系统分析员向用户初步了解需求,然后用word列出要开发的系统的大功能模块,每个大功能模块有哪些小功能模块,对于有些需求比较明确相关的界面时,在这一步里面可以初步定义好少量的界面.[1 ...

随机推荐

  1. GUI_文件管理器(练习)

    实现想windows下的文件管理器(主要是监听器里的方法,showDir()写法) package com.mywindow.test; import java.awt.event.ActionEve ...

  2. 关于前缀和,A - Hamming Distance Sum

    前缀和思想 Genos needs your help. He was asked to solve the following programming problem by Saitama: The ...

  3. oracle_使用udev绑定磁盘方法

    scsi_id命令发出一个SCSI INQUIRY指令给设备,访问vital product data (VPD)页0x83的数据,那里包含设备的WWID和其他的信息,或者页0x80的数据,那里包含单 ...

  4. Arduino IDE for ESP8266 ()esp8266项目 WIFI攻击器

    https://www.wandianshenme.com/play/esp8266-nodemcu-create-portable-wifi-jammer/ 使用 ESP8266 制作 WiFi 干 ...

  5. python3 练习题 day02

    '''1.有变量name = "aleX leNb" 完成如下操作:1)  移除 name 变量对应的值两边的空格,并输出处理结果2)  移除name变量左边的"al&q ...

  6. mysql函数之截取字符串

    文章摘取自http://www.cnblogs.com/zdz8207/p/3765073.html 练习截取字符串函数(五个) mysql索引从1开始 一.mysql截取字符串函数 1.left(s ...

  7. 最简单例子图解JVM内存分配和回收(转)

    本文转自http://ifeve.com/a-simple-example-demo-jvm-allocation-and-gc/ http://www.idouba.net/a-simple-exa ...

  8. Vue2---父子组件之间的访问

    个人小总结:1年多没有写博客,感觉很多知识点生疏了,虽然工作上能解决问题,但是当别人问到某个知识点的时候,还是迷迷糊糊的,所以坚持写博客是硬道理的,因为大脑不可能把所有的知识点记住,有可能某一天忘了, ...

  9. PAT A1123 Is It a Complete AVL Tree (30 分)——AVL平衡二叉树,完全二叉树

    An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child sub ...

  10. QT listwiget 控件添加图片

    很多的时候我们需要制作类似手机的中的电子相框, 可以用listwidget 控件实现 直接上代码 MainWindow::MainWindow(QWidget *parent) : QMainWind ...