题目:随机四则运算题目
采用语言:android
结对对象:李强 2013110421
双方贡献比例:1:1
编程照片:
核心代码:
package com.example.mldemo; import java.util.ArrayList; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; public class SecondActivity extends Activity { private ArrayList<String> operations=new ArrayList<String>(); private ArrayAdapter<String> numadapter; private ListView lv; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); // 取出mainactivity传递过来的数据 Intent intent = getIntent(); int num2 = intent.getIntExtra("data", -1); lv = (ListView) findViewById(R.id.listView1); for (int i = 0; i < num2; i++) { operations.add(operation()); } numadapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, operations); lv.setAdapter(numadapter); } public String operation() { int randomNum1; // 随机数第一个值 int randomNum2; // 随机数第二个值 String operation = null; int operator;// 运算符 operator = (int) (Math.random() * 4); randomNum1 = (int) (Math.random() * 100 + 1); randomNum2 = (int) (Math.random() * 100 + 1); // 通过if语句判断 if (operator == 0) { operation = (randomNum1 + "+" + randomNum2 + "=").toString(); } if (operator == 1) { operation = (randomNum1 + "-" + randomNum2 + "=").toString(); } if (operator == 2) { operation = (randomNum1 + "*" + randomNum2 + "=").toString(); } if (operator == 3) { operation = (randomNum1 + "/" + randomNum2 + "=").toString(); } return operation; } }
总结:
结对编程的优点:结合两个人的想法,可以得到一个比一个人想法更全面的想法,效率更加高,测试时也更加全面。完成速度快,收获也比一个人更加多。
学习进度条:
成就 |
学习时间 |
新编写代码行数 |
博客量(篇) |
学到的知识点 |
第一周 |
2h |
0 |
0 |
初步认识“软件工程” |
第二周 |
2h |
0 |
1 |
逐渐了解“软件工程”的思想 |
第三周 |
2h |
0 |
1 |
制作并进行问卷调查 |
第四周 |
4h |
120 |
2 |
需求分析与结对编程 |
第五周 |
4h |
360 |
0 |
android的学习 |
第六周 |
3h |
0 |
0 |
初步学习“软件测试” |
第七周 |
3h |
500 |
1 |
软件系统设计、结对编程 |