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

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

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

本次发布是在与团队成员解决了昨天问题的基础上,再增加了几个界面,增加了一些功能,修改与增加的代码如下:

修改的代码:

package com.example.calculator;

import java.util.*;

import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
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;
import android.content.Intent; public class CalculatorActivity extends Activity {
private final Random num1=new Random();
private final Random num2=new Random();
private final Random r = new Random();
private int x1;
private int x2;
private int x3; private TextView text1,text2,text3;
private EditText answer;
private Button surebutton;//确定按钮 private char[] ch={'+','-','*','/'}; //字符数组
private int index = r.nextInt(ch.length); //随机数,小于数组的长度数, 0~3
private char d=ch[index]; @Override
protected void onCreate(Bundle savedInstanceState) {
ActionBar actionBar=getActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calculator);
text1=(TextView)findViewById(R.id.textView1);//随机数字
text3=(TextView)findViewById(R.id.textView3);//随机数字
text2=(TextView)findViewById(R.id.textView2);//随机运算符号
answer=(EditText)findViewById(R.id.editText1); final String a=String.valueOf(num1.nextInt(100));
x1=Integer.valueOf(a);
final String b=String.valueOf(num2.nextInt(100));
x2=Integer.valueOf(b);
final String e=String.valueOf(d); text1.setText(a);
text3.setText(b);
text2.setText(e);
surebutton=(Button)findViewById(R.id.button);//确定按钮
surebutton.setOnClickListener(new OnClickListener() { @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
final String c=answer.getText().toString();
x3=Integer.valueOf(c);
if(index==0){
if(x3==x1+x2){
Toast.makeText(CalculatorActivity.this, "正确"+c, Toast.LENGTH_SHORT).show();
}
if(!(x3==x1+x2)){
Toast.makeText(CalculatorActivity.this, "错误"+c, Toast.LENGTH_SHORT).show();
}
}
if(index==1){
if(x3==x1-x2){
Toast.makeText(CalculatorActivity.this, "正确"+c, Toast.LENGTH_SHORT).show();
}
if(!(x3==x1-x2)){
Toast.makeText(CalculatorActivity.this, "错误"+c, Toast.LENGTH_SHORT).show();
}
}
if(index==2){
if(x3==x1*x2){
Toast.makeText(CalculatorActivity.this, "正确"+c, Toast.LENGTH_SHORT).show();
}
if(!(x3==x1*x2)){
Toast.makeText(CalculatorActivity.this, "错误"+c, Toast.LENGTH_SHORT).show();
}
}
if(index==3){
if(x3==x1/x2){
Toast.makeText(CalculatorActivity.this, "正确"+c, Toast.LENGTH_SHORT).show();
}
if(!(x3==x1/x2)){
Toast.makeText(CalculatorActivity.this, "错误"+c, Toast.LENGTH_SHORT).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;
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case android.R.id.home:
//创建启动MainActivity的Intent
Intent intent=new Intent(this,TypesActivity.class);
//添加额外的Flag,将Activity栈中处于MainActivity之上的Activity弹出
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
break; default:
break;
}
return super.onOptionsItemSelected(item);
} }

增加的代码:

package com.example.calculator;

import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button; public class TypesActivity extends Activity {
private Button btn1;
private Button btn2; @Override
protected void onCreate(Bundle savedInstanceState) {
ActionBar actionBar=getActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_types);
btn1=(Button)findViewById(R.id.button1);
btn2=(Button)findViewById(R.id.button2); btn1.setOnClickListener(new OnClickListener() { @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setClass(TypesActivity.this, CalculatorActivity.class);
startActivity(intent);
TypesActivity.this.finish();
}
});
btn2.setOnClickListener(new OnClickListener() { @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setClass(TypesActivity.this, CalculatorsActivity.class);
startActivity(intent);
TypesActivity.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.types, menu);
return true;
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case android.R.id.home:
//创建启动MainActivity的Intent
Intent intent=new Intent(this,MainActivity.class);
//添加额外的Flag,将Activity栈中处于MainActivity之上的Activity弹出
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
break; default:
break;
}
return super.onOptionsItemSelected(item);
} }

  增加了两个选择按钮“单题练习”与“多选择练习”;

“多选择练习”的布局界面:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/animal"
tools:context=".CalculatorsActivity" > <TableLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" > <TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入位数" /> <EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" > <requestFocus />
</EditText>
</TableRow> <TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" > <TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入题数" /> <EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
</TableRow> <TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" > <TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入时间" /> <EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="3"
android:inputType="number" /> <TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="分" /> <EditText
android:id="@+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="3"
android:inputType="number"/> <TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="秒" />
</TableRow> <TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
>
<RadioGroup
android:id="@+id/group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
> <RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/add" /> <RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/radio0"
android:layout_below="@+id/radio0"
android:text="@string/jian" /> <RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cheng" /> <RadioButton
android:id="@+id/radio3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/chu" />
</RadioGroup>
</TableRow> <TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" > </TableRow> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="开始" /> </TableLayout> </RelativeLayout>

  演示APP运行界面:

1)主界面:

2)选择界面:

3)单题练习:(解决成功)

   

4)多选择练习:

接下来的任务是继续完善“多选择练习”界面!加油!

小学四则运算APP 第一个冲刺阶段 第三天的更多相关文章

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

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

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

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

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

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

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

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

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

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

  6. 小学四则运算APP 第一个冲刺 第七天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是完成的功能一: 程序代码: MainActivity代码: import andr ...

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

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

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

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

  9. 小学四则运算APP 第二次冲刺 第四天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第二次冲刺阶段时间:11.29~12.09 本次发布的是合并后的选择题功能界面的设置: ChoiceSet.java: package c ...

随机推荐

  1. Tengine 2.1.2 (nginx/1.6.2)安装配置,淘宝 Web 服务器

    简介 Tengine是由淘宝网发起的Web服务器项目.它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性.Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很 ...

  2. 流式套接字:基于TCP协议的Socket网络编程(案例2)

    案例:在案例1的基础上实现一个服务器对应多个客户端(多线程),且获得每个客户端的IP. 线程代码: package com.yh.mySocket; import java.io.BufferedRe ...

  3. Git同时使用不同平台代码仓库

    问题描述 公司项目使用代码仓库为gitinn/gitlab等,个人项目使用github进行托管,而公司项目和个人项目设置的邮箱和用户名是不同的,而ssh的密钥对又是基于这两个信息生成的,所以此时想要同 ...

  4. JAVA框架 Spring 事务

    一.我们之前在hibernate的时候,需要直接写事务,需要绑定当前线程保证获取同一个连接,虽然hibernate的帮我们封装绑定当前现成的操作,但是需要我们手动的去开启和关闭事务. 而spring帮 ...

  5. Ubuntu 中使用git 上传代码

    现在很多人都愿意把自己的代码分享给大家,所以有很多的代码管理的软件 ,比如SVN Git 等软件.今天就讲一下  git 的简单的应用,上传代码.用 git 上传代码 要有个git 账号,这是必不少的 ...

  6. 前端性能优化:Add Expires headers

    前端性能优化:Add Expires headers Expires headers 是什么? Expires headers:直接翻译是过期头.Expires headers 告诉浏览器是否应该从服 ...

  7. day35

    今日内容: 1.进程间互相通信(IPC机制) 2.生产者消费者模型 3.线程理论 4.线程开启的两种方式 5.线程相关属性方法 6.守护线程 7.线程互斥锁 1.进程间相互通信(IPC机制) 主要是一 ...

  8. golang交叉编译:Linux - Windows

    环境:Debian jessiego 1.7.4Windows 7 背景: 在debian中写好的程序编译后在windows上运行. 程序中使用了sqlite3 import( _ "git ...

  9. Kafka 集群部署

    kafka是一个分布式消息队列,需要依赖ZooKeeper,请先安装好zk集群 kafka安装包解压 $ -0.9.0.1.tgz $ -0.9.0.1 /usr/kafka $ cd /usr/ka ...

  10. Struts2_learning

    一.这是我学习struts2所做的一个记录,因为整个过程较为麻烦,所以,记录下来,以便以后使用 过程: 步骤: 1)dynamic web project 2)jars 3)struts.xml pa ...