Skip to content

Instantly share code, notes, and snippets.

@ericlucero
Last active July 29, 2016 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericlucero/75a1a022591ddff2fc778b8b2e9ef4f6 to your computer and use it in GitHub Desktop.
Save ericlucero/75a1a022591ddff2fc778b8b2e9ef4f6 to your computer and use it in GitHub Desktop.
Contador de Puntos para BasketBall
package com.example.android.courtcounter;
import android.os.ParcelUuid;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
int scoreTeamA = 0;
int scoreTeamB = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
displayForTeamA(0);
}
//This method is called when the order button is clicked.
public void resetea(View view) {
scoreTeamA = 0;
scoreTeamB = 0;
displayForTeamA(scoreTeamA);
displayForTeamB(scoreTeamB);
}
//This method is called when the order button is clicked.
public void SumaTresTeamA(View view) {
scoreTeamA= scoreTeamA+ 3;
displayForTeamA(scoreTeamA);
}
//This method is called when the order button is clicked.
public void SumaDosTeamA(View view) {
scoreTeamA= scoreTeamA+ 2;
displayForTeamA(scoreTeamA);
}
public void SumaUnoTeamA(View view) {
scoreTeamA= scoreTeamA+ 1;
displayForTeamA(scoreTeamA);
}
// Suma uno para el scoreTeamB
public void SumaTresTeamB(View view){
scoreTeamB = scoreTeamB + 3;
displayForTeamB(scoreTeamB);
}
// Suma uno para el scoreTeamB
public void SumaDosTeamB(View view){
scoreTeamB = scoreTeamB + 2;
displayForTeamB(scoreTeamB);
}
// Suma uno para el scoreTeamB
public void SumaUnoTeamB(View view){
scoreTeamB = scoreTeamB + 1;
displayForTeamB(scoreTeamB);
}
// * Displays the given scoreTeamAfor Team A.
public void displayForTeamA(int score) {
TextView scoreView = (TextView) findViewById(R.id.team_a_score);
scoreView.setText(String.valueOf(score));
}
// * Displays the given scoreTeamAfor Team B.
public void displayForTeamB(int score) {
TextView scoreView = (TextView) findViewById(R.id.team_b_score);
scoreView.setText(String.valueOf(score));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment