四则运算第一次冲刺

---恢复内容开始---

小组成员:黄国柱 博客地址    http://www.cnblogs.com/zzhuzi/

              欧泽波 博客地址    http://www.cnblogs.com/OuZeBo/

第一阶段的冲刺,由于这个学期学了Android,所以代码用的是Android;

第一阶段我们完成了APP的框架;代码如下

MainActivity.java

package com.example.brdemo;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {
public Button btn,btn1,btn2;
private MyReceiver receiver;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn=(Button)findViewById(R.id.button1);
        btn1=(Button)findViewById(R.id.button2);
        btn2=(Button)findViewById(R.id.button3);
        btn.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent intent=new Intent();
                intent.setAction("AA");
                intent.putExtra("msg", "简单的消息");
                sendBroadcast(intent);
            }
        });
        btn1.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                receiver=new MyReceiver();
                IntentFilter filter=new IntentFilter();
                filter.addAction("AA");
                registerReceiver(receiver, filter);
            }
        });
        btn2.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                unregisterReceiver(receiver);
            }
        });
    }

    @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;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

main_activity.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="@drawable/picture">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="130dp" >

        <ImageView
            android:id="@+id/imageView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:src="@drawable/picture0005" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent" >

        <Button
            android:id="@+id/start_game_button"
            android:layout_width="200dp"
            android:layout_height="60dp"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_centerInParent="true"
            android:background="@drawable/button_1"
            android:text="@string/start_game"
            android:paddingLeft="50dp"
            android:textSize="28sp" 
            android:onClick="grade"/>

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="55dp"
            android:layout_height="55dp"
            android:layout_above="@+id/challenge_button"
            android:layout_alignLeft="@+id/start_game_button"
            android:layout_alignParentTop="true"
            android:paddingLeft="5dp"
            android:src="@drawable/picture0001" />

        
        <Button
            android:id="@+id/challenge_button"
            android:layout_width="200dp"
            android:layout_height="60dp"
            android:layout_centerInParent="true"
            android:layout_alignLeft="@+id/start_game_button"
            android:layout_below="@+id/start_game_button"
            android:background="@drawable/button_1"
            android:layout_marginTop="15dp"
            android:text="@string/challenge"
            android:paddingLeft="50dp"
            android:textSize="28sp"/>
        
        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="55dp"
            android:layout_height="55dp"
            android:layout_above="@+id/help_button"
            android:layout_alignLeft="@+id/challenge_button"
            android:paddingLeft="5dp"
            android:src="@drawable/picture0002" />
        
        
        <Button
            android:id="@+id/help_button"
            android:layout_width="200dp"
            android:layout_height="60dp"
            android:layout_centerInParent="true"
            android:layout_alignLeft="@+id/challenge_button"
            android:layout_below="@+id/challenge_button"
            android:background="@drawable/button_1"
            android:layout_marginTop="15dp"
            android:text="@string/help" 
            android:paddingLeft="50dp"
            android:textSize="28sp"/>
        
          <ImageView
            android:id="@+id/imageView3"
            android:layout_width="55dp"
            android:layout_height="55dp"
            android:layout_above="@+id/exit_game_button"
            android:layout_alignLeft="@+id/help_button"
            android:paddingLeft="5dp"
            android:src="@drawable/picture0003" />
        
        
        <Button
            android:id="@+id/exit_game_button"
            android:layout_width="200dp"
            android:layout_height="60dp"
            android:layout_centerInParent="true"
            android:layout_alignLeft="@+id/help_button"
            android:layout_below="@+id/help_button"
            android:background="@drawable/button_1"
            android:layout_marginTop="15dp"
            android:text="@string/exit_game" 
            android:paddingLeft="50dp"
            android:textSize="28sp"
            android:onClick="exit"/>

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="55dp"
            android:layout_height="55dp"
            android:layout_alignBottom="@+id/exit_game_button"
            android:layout_alignLeft="@+id/exit_game_button"
            android:paddingLeft="5dp"
            android:src="@drawable/picture0004" />

      
    </RelativeLayout>

</LinearLayout>

 

CountActivity.java

package com.example.fouroperations;



import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class CountActivity extends Activity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_count);
        
     }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.count, menu);
        return true;
    }
    
}

activity_count.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:background="@drawable/biankuang_1" 
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:orientation="vertical" >
            
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1">

                <TextView
                    android:id="@+id/count_textView1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center_vertical"
                    android:text=""
                    android:textSize="35sp"/>

            </RelativeLayout>
            
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1">

                <TextView
                    android:id="@+id/count_textView2"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center_vertical|right"
                    android:text=""
                    android:hint="@string/please"
                    android:textSize="40sp"/>

            </RelativeLayout>
            
            
        </LinearLayout>

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginTop="5dp" >

            <Button
                android:id="@+id/button1"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="3dp"
                android:background="@drawable/button_3"
                android:text="@string/one" />

            <Button
                android:id="@+id/button2"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="5dp"
                android:background="@drawable/button_3"
                android:text="@string/two" />
            <Button
                android:id="@+id/button3"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="5dp"
                android:background="@drawable/button_3"
                android:text="@string/three" />
            <Button
                android:id="@+id/button10"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="2dp"
                android:background="@drawable/button_3"
                android:text="@string/back" />
            
        </LinearLayout>

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">
        
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true" 
            android:layout_marginTop="5dp">

            <Button
                android:id="@+id/button4"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="3dp"
                android:background="@drawable/button_3"
                android:text="@string/four" />

            <Button
                android:id="@+id/button5"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="5dp"
                android:background="@drawable/button_3"
                android:text="@string/five" />
            <Button
                android:id="@+id/button6"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="5dp"
                android:background="@drawable/button_3"
                android:text="@string/six" />

            <Button
                android:id="@+id/button11"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="2dp"
                android:layout_weight="1.0"
                android:background="@drawable/button_3"
                android:text="@string/point"
                android:textSize="60sp" />
            
        </LinearLayout>
        
    </RelativeLayout>
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">
        
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true" 
            android:layout_marginTop="5dp">

            <Button
                android:id="@+id/button7"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="3dp"
                android:background="@drawable/button_3"
                android:text="@string/seven" />

            <Button
                android:id="@+id/button8"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="5dp"
                android:background="@drawable/button_3"
                android:text="@string/eight" />
            <Button
                android:id="@+id/button9"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="5dp"
                android:background="@drawable/button_3"
                android:text="@string/nine" />

            <Button
                android:id="@+id/button12"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="2dp"
                android:layout_weight="1.0"
                android:background="@drawable/button_3"
                android:text="@string/minus"
                android:textSize="55sp" />
            
        </LinearLayout>
        
     </RelativeLayout>
     
     <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">

         <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true" 
            android:layout_marginTop="5dp">

            <Button
                android:id="@+id/button13"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="3dp"
                android:background="@drawable/button_3"
                android:text="@string/diagonal" />

            <Button
                android:id="@+id/button0"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:textSize="40sp"
                android:layout_marginLeft="5dp"
                android:background="@drawable/button_3"
                android:text="@string/zero" />
            <Button
                android:id="@+id/button14"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="2.0"
                android:textSize="40sp"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="2dp"
                android:background="@drawable/button_4"
                android:text="@string/affirm" />
           
            
        </LinearLayout>
     
     </RelativeLayout>
     
     
</LinearLayout>

效果图

StartMenuActivity,java

package com.example.fouroperations;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;

public class StartMenuActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start_menu);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.start_menu, menu);
        return true;
    }
    
    public void simple_button(View view){
        
        Intent intent = new Intent();
        intent.setClass(this, CountActivity.class);
        this.startActivity(intent);
        
    }
    
    public void general_button(View view){
        
        
    }
    
    public void more_difficul_button(View view){
        
        
    }
    
    public void difficult_button(View view){
        
        
    }

}

activity_start.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="@drawable/picture02">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_marginTop="50dp">

        <Button
            android:id="@+id/simple_button"
            android:layout_width="200dp"
            android:layout_height="fill_parent"
            android:layout_centerInParent="true"
            android:layout_marginRight="39dp"
            android:text="@string/simple"
            android:textSize="40sp" 
            android:onClick="simple_button"/>

    </RelativeLayout>
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_marginTop="20dp" >
        
        <Button
            android:id="@+id/general_button"
            android:layout_width="200dp"
            android:layout_height="fill_parent"
            android:layout_centerInParent="true"
            android:layout_marginLeft="53dp"
            android:text="@string/general"
            android:textSize="40sp" 
            android:onClick="general_button"/>
        
    </RelativeLayout>
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_marginTop="20dp" >
        
        <Button
            android:id="@+id/more_difficul_button"
            android:layout_width="200dp"
            android:layout_height="fill_parent"
            android:layout_centerInParent="true"
            android:layout_marginLeft="53dp"
            android:text="@string/more_difficult"
            android:textSize="40sp" 
            android:onClick="more_difficul_button"/>
        
    </RelativeLayout>
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_marginTop="20dp">
        
        <Button
            android:id="@+id/difficult_button"
            android:layout_width="200dp"
            android:layout_height="fill_parent"
            android:layout_centerInParent="true"
            android:layout_marginLeft="53dp"
            android:text="@string/difficult"
            android:textSize="40sp" 
            android:onClick="difficult_button"/>
        
    </RelativeLayout>

</LinearLayout>

效果图

由于我们第一阶段的工作量较少,所以并未采用燃尽图来表示我们的工作量。

从第二阶段开始我们开始完善程序,并详细记录我们的分工,每日进展等。

第一阶段的冲刺就是如此。

原文地址:https://www.cnblogs.com/zzhuzi/p/4982618.html