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

团队选题:小学四则运算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);//运算结果
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);
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();
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;
} }

新功能选择页面代码:

<?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="23dp"
android:text="@string/title_activity_choice"
android:textSize="20sp" /> <TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="33dp"
android:text="TextView"
android:textSize="20sp" /> <RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_centerHorizontal="true"
android:layout_marginTop="44dp" > <RadioButton
android:id="@+id/R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="20sp" /> <RadioButton
android:id="@+id/R2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="20sp" /> <RadioButton
android:id="@+id/R3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="20sp" /> <RadioButton
android:id="@+id/R4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="20sp" />
</RadioGroup> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/radioGroup1"
android:layout_marginTop="34dp"
android:text="下一题" /> </RelativeLayout>

<?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="35dp"
android:text="@string/title_activity_set"
android:textSize="30sp" /> <EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView2"
android:layout_alignLeft="@+id/textView1"
android:ems="10"
android:inputType="number" /> <TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_marginTop="41dp"
android:layout_toLeftOf="@+id/editText1"
android:text="@string/the_number_of_calculator"
android:textSize="20sp" /> <RadioButton
android:id="@+id/radioButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/radioButton3"
android:layout_alignBottom="@+id/radioButton3"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@+id/textView1"
android:text="/" /> <RadioButton
android:id="@+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/radioButton2"
android:layout_alignBottom="@+id/radioButton2"
android:layout_alignRight="@+id/textView1"
android:layout_marginRight="18dp"
android:text="*" /> <RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/radioButton1"
android:layout_alignBottom="@+id/radioButton1"
android:layout_toRightOf="@+id/textView2"
android:text="-" /> <RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="16dp"
android:text="+" /> <EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView3"
android:layout_toLeftOf="@+id/radioButton3"
android:layout_toRightOf="@+id/textView3"
android:ems="10"
android:inputType="number" /> <TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView3"
android:layout_alignBottom="@+id/textView3"
android:layout_alignLeft="@+id/radioButton3"
android:text="分"
android:textSize="20sp" /> <TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/radioButton1"
android:layout_below="@+id/radioButton1"
android:layout_marginTop="58dp"
android:text="时间设置:"
android:textSize="20sp" /> <EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView4"
android:layout_alignRight="@+id/radioButton4"
android:layout_marginLeft="16dp"
android:layout_toRightOf="@+id/textView4"
android:ems="10"
android:inputType="number" > <requestFocus />
</EditText> <TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView4"
android:layout_alignBottom="@+id/textView4"
android:layout_alignParentRight="true"
android:text="秒"
android:textSize="20sp"/> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/editText2"
android:layout_marginTop="43dp"
android:text="确定" /> </RelativeLayout>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

随机推荐

  1. python第三十课--异常(异常对象传递过程)

    演示异常对象传递的过程(往上“抛”),并将其解决 def func1(): print('func1...') print(10/0) def func2(): print('func2...') t ...

  2. oneinstack远程管理数据库

    本篇文章主要内容是本地工具连接数据非网页(网站)连接 如果你想使用网页(网站)连接远程数据库,请看下面的官网教程 OneinStack如何配置MySQL远程连接? 为了安全考虑,OneinStack仅 ...

  3. Linux命令——磁盘管理

    Linux命令--磁盘管理 命令df 作用:查看已挂载磁盘的总容量.使用容量.剩余容量等 参数:-i,查看inodes的使用状况 参数:-h,使用合适的单位显示(推荐) 命令du 作用:查看某个目录或 ...

  4. [转]深入理解MFC中程序框架

    最近抽空复习了一下MFC的内容,觉得一篇博文写的不错. 原文内容太多直接给出链接吧:深入理解MFC中程序框架 链接2:深入浅出话VC++(2)——MFC的本质 链接3:MFC单文档/视图结构穷追猛打

  5. Android 调用手机上第三方百度地图并传值给地图

    //移动APP调起Android百度地图方式举例 Intent intent = null; try { // intent = Intent.getIntent("intent://map ...

  6. iOS11 Xcode 9 按住command 单击 恢复到从前(直接跳转到定义)

    iOS11 Xcode 9  按住command 单击 恢复到从前(直接跳转到定义)   2017年9月20日,苹果如期推送 Xcode 9 和 iOS 11的更新. Xcode 9正式版与之前bet ...

  7. php操作url 函数等

    pathinfo() - Returns information about a file path parse_str() - Parses the string into variables pa ...

  8. 将jar文件加到Maven的local repository中

    对于Maven项目来说,日常使用的多数第三方java库文件都可以从Maven的Central Repository中自动下载,但是如果我们需要的jar文件不在Central Repository中,那 ...

  9. Eclipse添加Junit测试

    项目上右键,点击build path->add libraaies->选择Junit 附上惨不忍睹的图(eclipse里展开菜单项时老截屏截不好,不知各位有没有好点的解决方案) 2017. ...

  10. 2017-2018-2 『网络对抗技术』Exp3:免杀原理与实践

    1. 免杀原理与实践说明 一.实验说明 任务一:正确使用msf编码器,msfvenom生成如jar之类的其他文件,veil-evasion,自己利用shellcode编程等免杀工具或技巧:(1.5分) ...