Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Software Engineering / Android Studio The purpose of this lab assignment is to h

ID: 667362 • Letter: S

Question

Software Engineering / Android Studio

The purpose of this lab assignment is to help you get started with Android programming. It will introduce you to the syntax and semantics of Android/Java along with the mechanics of using Eclipse with the Android plugin. The lab assignment is to create an Android application that can function as a ball-strike counter an umpire might use during a baseball game to keep track of the count for a batter. For now, the application only needs to keep track of balls and strikes for a single batter. In a future assignment, I may have you extend it to keep track of outs and/or innings. (If you want to add extra features during assignment #1, have at it.) If the count reaches 3 strikes first, your application should display a dialog box announcing the batter is Out!. If the count reaches 4 balls first, your application should display a dialog box announcing Walk!. After either one, the count should be reset for the next batter. The final result should look something like:

Explanation / Answer

activity_main.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"
tools:context="com.example.addition.MainActivity" >

  

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="33dp>

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText2"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp>

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_toRightOf="@+id/textView2"
android:text="Strike" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_toRightOf="@+id/textView2"
android:text="Ball" />

  

</RelativeLayout>

MainActivity.java

package com.example.addition;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;


public class MainActivity extends ActionBarActivity {
TextView tv,tv1;
Button b1,b2;

int a1,a2,c1,d1;
String s1,s2,s3,s4;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView) findViewById(R.id.textView1);

tv1 = (TextView) findViewById(R.id.textView2);
b1= (Button) findViewById(R.id.button1);
b2= (Button) findViewById(R.id.button2);
  
  
b1.setOnClickListener(new View.OnClickListener() {
          
           @Override
           public void onClick(View arg0) {
               // TODO Auto-generated method stub
c1=c1+1;
  
               s3=String.valueOf(c1);
               tv.setText("Strick :- " + s3);
           }
       });
      
}


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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote