Last active
August 28, 2018 18:01
-
-
Save Soufiane-Aou/024b3c6a78198e4406fbe4e521ae9036 to your computer and use it in GitHub Desktop.
Score Keeper App Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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"> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="horizontal" | |
tools:context=".MainActivity"> | |
<LinearLayout | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:orientation="vertical"> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:gravity="center" | |
android:text="F.C.B" | |
android:layout_marginTop="16dp" | |
android:layout_marginBottom="16dp" | |
android:fontFamily="sans-serif-medium" | |
android:textColor="#616161" | |
android:textSize="14sp"/> | |
<TextView | |
android:id="@+id/team_FCB" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="0" | |
android:textSize="45sp" | |
android:textColor="#000000" | |
android:gravity="center" | |
/> | |
<Button | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="gol!" | |
android:onClick="team_A_gol" | |
android:layout_margin="15dp" | |
/> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="0" | |
android:id="@+id/yellow_card" | |
android:textSize="45sp" | |
android:textColor="#000000" | |
android:gravity="center" | |
/> | |
<Button | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="yellow" | |
android:onClick="team_A_Yellow" | |
android:layout_margin="15dp"/> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="0" | |
android:id="@+id/red_card" | |
android:textSize="45sp" | |
android:textColor="#000000" | |
android:gravity="center"/> | |
<Button | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="red" | |
android:onClick="team_A_Red" | |
android:layout_margin="15dp"/> | |
</LinearLayout> | |
<View | |
android:layout_width="1dp" | |
android:layout_height="match_parent" | |
android:background="#000000" | |
android:layout_marginTop="16dp"/> | |
<LinearLayout | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:orientation="vertical"> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:gravity="center" | |
android:text="R.M.A" | |
android:layout_marginTop="16dp" | |
android:layout_marginBottom="16dp" | |
android:fontFamily="sans-serif-medium" | |
android:textColor="#616161" | |
android:textSize="14sp" | |
/> | |
<TextView | |
android:id="@+id/team_RMA" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="0" | |
android:textSize="45sp" | |
android:textColor="#000000" | |
android:gravity="center"/> | |
<Button | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="gol!" | |
android:onClick="team_B_Gol" | |
android:layout_margin="15dp"/> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="0" | |
android:id="@+id/yellow_card_RMA" | |
android:textSize="45sp" | |
android:textColor="#000000" | |
android:gravity="center"/> | |
<Button | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="yellow" | |
android:onClick="team_B_Yellow" | |
android:layout_margin="15dp"/> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="0" | |
android:id="@+id/red_card_RMA" | |
android:textSize="45sp" | |
android:textColor="#000000" | |
android:gravity="center"/> | |
<Button | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="red" | |
android:onClick="team_B_Red" | |
android:layout_margin="15dp"/> | |
</LinearLayout> | |
</LinearLayout> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentBottom="true" | |
android:layout_centerHorizontal="true" | |
android:layout_marginBottom="14dp" | |
android:onClick="Rest" | |
android:text="RESET" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.android.scorekeeper; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.TextView; | |
public class MainActivity extends AppCompatActivity { | |
int golsTeamA=0; | |
int yellowCardA=0; | |
int redCardA =0; | |
int golsTeamB=0; | |
int yellowCardB=0; | |
int redCardB =0; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
} | |
/** | |
*increase the gol by 1 for team A | |
*/ | |
public void team_A_gol(View v){ | |
golsTeamA = golsTeamA+1; | |
displayForFcb(golsTeamA); | |
} | |
/** | |
*increase the yellow card by 1 | |
*/ | |
public void team_A_Yellow(View v){ | |
yellowCardA =yellowCardA +1; | |
displayCardYellowA(yellowCardA); | |
} | |
/** | |
*increase the red card by 1 | |
*/ | |
public void team_A_Red(View v){ | |
redCardA =redCardA+1; | |
displayCardRedA(redCardA); | |
} | |
//*********************************************************** | |
//_____________________________________________________ | |
/** | |
*increase the gol by 1 team B | |
*/ | |
public void team_B_Gol(View v){ | |
golsTeamB = golsTeamB+1; | |
displayForRma(golsTeamB); | |
} | |
/** | |
*increase the yellow card for team B by 1 | |
*/ | |
public void team_B_Yellow(View v){ | |
yellowCardB = yellowCardB+1; | |
displayYellowCardRMA(yellowCardB); | |
} | |
/** | |
*increase the red card by 1 | |
*/ | |
public void team_B_Red(View v){ | |
redCardB =redCardB+1; | |
displayRedCardRMA(redCardB); | |
} | |
public void Rest(View v){ | |
golsTeamA=0; | |
displayForFcb(golsTeamA); | |
yellowCardA=0; | |
displayCardYellowA(yellowCardA); | |
redCardA =0; | |
displayCardRedA(redCardA); | |
golsTeamB=0; | |
displayForRma(golsTeamB); | |
yellowCardB=0; | |
displayYellowCardRMA(yellowCardB); | |
redCardB =0; | |
displayRedCardRMA(redCardB); | |
} | |
/** | |
* Displays the given score for Team fcbarcalona. | |
*/ | |
public void displayForFcb(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.team_FCB); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Displays the given yellow card score for Team fcbarcalona. | |
*/ | |
public void displayCardYellowA(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.yellow_card); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Displays the given Red card score for Team fcbarcalona. | |
*/ | |
public void displayCardRedA(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.red_card); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Displays the given score for Team real madrid. | |
*/ | |
public void displayForRma(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.team_RMA); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Displays the given score for Team real madrid. | |
*/ | |
public void displayYellowCardRMA(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.yellow_card_RMA); | |
scoreView.setText(String.valueOf(score)); | |
} | |
/** | |
* Displays the given score for Team real madrid. | |
*/ | |
public void displayRedCardRMA(int score) { | |
TextView scoreView = (TextView) findViewById(R.id.red_card_RMA); | |
scoreView.setText(String.valueOf(score)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.AppCompat.Light"> | |
<!-- Primary theme color of the app (sets background color of app bar) --> | |
<item name="colorPrimary">#64B5F6</item> | |
<!-- Background color of buttons in the app --> | |
<item name="colorButtonNormal">#42A5F5</item> | |
</style> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The goal is to create an Score Keeper app which gives a user the ability to keep track of the score of two different teams playing a game of your choice. To build this project, you can follow along with the practice set and customize the Court Counter app to track scores from a different sport.