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

时间:2021-08-23 00:10:38

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

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

第二次冲刺阶段时间:11.29~12.09

本次发布的是已完成的功能二(选择题):

ChoiceActivity.java:

package com.example.calculator;

import java.util.Random;

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.CheckBox;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast; public class ChoiceActivity extends Activity {
private TextView text1,text2,text3;
private CheckBox checkbox1,checkbox2,checkbox3,checkbox4;
private Button btn; private final Random num1=new Random();
private final Random num2=new Random();
private final Random num3=new Random();
private final Random r = new Random();
private int x1;
private int x2;
private int x3; 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_choice);
text1=(TextView)findViewById(R.id.textView1);
text2=(TextView)findViewById(R.id.textView2);
text3=(TextView)findViewById(R.id.textView3); checkbox1=(CheckBox)findViewById(R.id.checkBox1);
checkbox2=(CheckBox)findViewById(R.id.checkBox2);
checkbox3=(CheckBox)findViewById(R.id.checkBox3);
checkbox4=(CheckBox)findViewById(R.id.checkBox4);
btn=(Button)findViewById(R.id.button1); 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 c=String.valueOf(num3.nextInt(100));
final String e=String.valueOf(d); text1.setText(a);
text3.setText(b);
text2.setText(e); checkbox1.setText(a);
checkbox2.setText(b);
checkbox4.setText(c); if(index==0){
x3=x1+x2;
final String h=String.valueOf(x3);
checkbox3.setText(h);
}
if(index==1){
x3=x1-x2;
final String h=String.valueOf(x3);
checkbox3.setText(h);
}
if(index==2){
x3=x1*x2;
final String h=String.valueOf(x3);
checkbox3.setText(h);
}
if(index==3){
x3=x1/x2;
final String h=String.valueOf(x3);
checkbox3.setText(h);
} btn.setOnClickListener(new OnClickListener() {
final String h=String.valueOf(x3);
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(checkbox3.isChecked()){
Toast.makeText(ChoiceActivity.this, "正确", Toast.LENGTH_SHORT).show();
}
if(!(checkbox3.isChecked())){
Toast.makeText(ChoiceActivity.this, "错误"+h, 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.choice, 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);
} }

activity_choice.xml:

<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=".ChoiceActivity" > <TextView
android:id="@+id/textView1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginTop="100dp" /> <TextView
android:id="@+id/textView2"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_toRightOf="@+id/textView1" /> <TextView
android:id="@+id/textView3"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_toRightOf="@+id/textView2" /> <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_toRightOf="@+id/textView3"
android:text="=" /> <CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/checkBox1"
android:layout_below="@+id/checkBox1"
android:layout_marginTop="14dp" /> <CheckBox
android:id="@+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/checkBox2"
android:layout_below="@+id/checkBox2"
android:layout_marginTop="17dp" /> <CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" /> <CheckBox
android:id="@+id/checkBox4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignLeft="@+id/checkBox3" /> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="确定" /> </RelativeLayout>

运行结果:

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

按“选择题练习”按钮后:

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

选择正确答案后显示正确:

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

选择错误答案后显示错误:

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

虽然功能实现了,可是界面还不美观,继续完善!

                                                                                                                                    

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

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

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

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

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第二次冲刺阶段时间:11.29~12.09 本次发布的判断题功能界面的设置: activity_panduan_set.xml: < ...

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

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第二次冲刺阶段时间:11.29~12.09 本次发布的是判断题代码,已经实现部分功能,,但是美中不足的是判断错误 panduanset.j ...

  4. 小学四则运算APP 第二阶段冲刺-第三天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第二次冲刺阶段时间:11.29~12.09 本次发布的是判断题的部分代码 panduanset.java import com.examp ...

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

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

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

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

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

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

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

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第三次冲刺阶段时间:12.12~12.19 本次发布的是音乐播放功能,可以根据用户需求一边播放音乐一边做题,也拥有暂停播放音乐的功能,增强 ...

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

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

随机推荐

  1. 【转】Mysql联合查询union和union all的使用介绍

    Mysql的联合查询命令UNION和UNION ALL,总结了使用语法和注意事项,以及学习例子和项目例子,需要的朋友可以参考下 一.UNION和UNION ALL的作用和语法 UNION 用于合... ...

  2. Android项目实战(二十五):Android studio 混淆&plus;打包&plus;验证是否成功

    前言: 单挑Android项目,最近即时通讯用到环信,集成sdk的时候 官方有一句 在 ProGuard 文件中加入以下 keep. -keep class com.hyphenate.** {*;} ...

  3. ocx控件 编译成C&num;调用的dll 方法 转

      打开VS命令提示行 1.注册ActiveX控件(带上 VCbox.ocx的路径) regsvr32  VCbox.ocx 2.编译OCX文件 aximp VCbox.ocx 生成两个dll文件,项 ...

  4. IE 11 保护模式害惨了我

    花了几乎两天,一直用IE, 就说好好的 动态域名 为什么一直不能访问.用其它浏览器一试,我哭了,都是好的.

  5. 设计模式之UML类图的常见关系(一)

    本篇会讲解在UML类图中,常见几种关系: 泛化(Generalization),依赖(Dependency),关联(Association),聚合(Aggregation),组合(Compositio ...

  6. js如何将纯数字字符串转换为long型

    1.js如何将纯数字字符串转换为long型? js 中 int的存储位数?最大十进制数表示是多少? 精度http://www.jb51.net/article/59808.htm 整数(不使用小数点或 ...

  7. app后端设计--总目录

    做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里).其中的乐与苦 ...

  8. openstack私有云布署实践【14&period;1 登录页dashboard-controller(科兴环境)】

    2台kxcontroller安装组件 # yum install openstack-dashboard -y   修改一样的配置 vi /etc/openstack-dashboard/local_ ...

  9. &lbrack;LeetCode&rsqb; Best Time to Buy and Sell Stock 6道合集【DP】

    1. Best Time to Buy and Sell Stock 2. Best Time to Buy and Sell Stock II 3. Best Time to Buy and Sel ...

  10. 解决SVN 每次操作都需要重输入用户名密码问题

    把目录C:\Users\当前账号\AppData\Roaming\Subversion\auth下的文件删除,然后重启hbuilder或eclipse工具,重新输入账号密码之后,保存即可解决该问题.