Skip to content

Commit

Permalink
* Free New Version
Browse files Browse the repository at this point in the history
  • Loading branch information
Reepeecheep committed Mar 20, 2020
1 parent 15feb9f commit 17bf9a5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.numguesser.tonio_rpchp.numberguesser"
minSdkVersion 14
targetSdkVersion 28
versionCode 11
versionName "4.0.1"
versionCode 12
versionName "4.1.0"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected void onCreate(Bundle savedInstanceState) {
start_game();

final TextView tries_label = findViewById(R.id.tries_label);
final TextView last_try_label = findViewById(R.id.last_try_label);
final EditText number_txt = findViewById(R.id.number);
final Button button = findViewById(R.id.guess_button);

Expand All @@ -70,17 +71,20 @@ public void onClick(View v) {
else if (num == rnd) {
switch_image(R.drawable.android_genio_sad);
Alert(getString(R.string.end_game), getString(R.string.win), 1);
last_try_label.setText(getString(R.string.win));
vibrate();
}
else{
attempt--;
tries_label.setText(getString(R.string.tries_text) + attempt);
tries_label.setText(String.format("%s %d ",getString(R.string.tries_text), attempt));

if (attempt > 0){
check_rand(num, rnd);
String result = check_rand(num, rnd);
last_try_label.setText(result);
}
else {
Alert(getString(R.string.end_game), getString(R.string.lose)+rnd, 1);
last_try_label.setText(String.format("%s %d ", getString(R.string.lose), rnd));
}
}
}
Expand Down Expand Up @@ -153,18 +157,17 @@ public void run() {
alertDialog.dismiss();
}
}
} , 3000
} , 2500
);
}

//alertDialog.show();
}

public void check_rand(Integer input_number, Integer rnd){
public String check_rand(Integer input_number, Integer rnd){
String Tittle = "";
String Text = getString(R.string.more);


if (input_number > rnd){
Text = getString(R.string.less);
}
Expand All @@ -180,12 +183,18 @@ public void check_rand(Integer input_number, Integer rnd){

Alert(Tittle, Text, 0);

if (Tittle != ""){
Text = String.format("%s, %s", Tittle, Text);
}

String msg = String.format("(%d) %s", input_number, Text);

return msg;
}
public void vibrate(){
Vibrator v = (Vibrator) getSystemService(this.VIBRATOR_SERVICE);
v.vibrate(500);


// Vibrate for 500 milliseconds
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
v.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE));
Expand All @@ -206,6 +215,8 @@ public void start_game(){
rnd = rand_num.nextInt(100) + 1;
attempt = 5;
final TextView tries_label = findViewById(R.id.tries_label);
tries_label.setText(getString(R.string.tries_text)+ attempt);
final TextView last_try_label = findViewById(R.id.last_try_label);
tries_label.setText(String.format("%s %d ",getString(R.string.tries_text), attempt));
last_try_label.setText("");
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_guesser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
android:textColor="#00C000"
android:textSize="30sp" />

<TextView
android:id="@+id/last_try_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:textColor="#00C000"
android:textSize="15sp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down

0 comments on commit 17bf9a5

Please sign in to comment.