package com.example.melodic.higherorlower;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import java.util.Random;

public class MainActivity extends AppCompatActivity {

    int randomNumber;

    public void checkGuess(View view){

        EditText guessedNumber = (EditText) findViewById(R.id.editNumber);
        if(!(guessedNumber.getText().toString().isEmpty())){

        String guessedNumberString = guessedNumber.getText().toString();

        int guessedNumberInt = Integer.parseInt(guessedNumberString);
        String message = "";

        if (guessedNumberInt == (int)guessedNumberInt) {

            if (guessedNumberInt > randomNumber) {
                message = "High!";
            } else if (guessedNumberInt < randomNumber) {
                message = "Low";
            } else if (guessedNumberInt == randomNumber) {
                message = "Correct";
            } else {
                message = "No number was given!";
            }
            System.out.println("Random Number: " + randomNumber);
            Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();

        } else{
            Toast.makeText(getApplicationContext(), "Not a number", Toast.LENGTH_LONG).show();
        }
        } else {
            Toast.makeText(getApplicationContext(), "You did not type!", Toast.LENGTH_LONG).show();
        }
    }

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

        Random randomGenerator  = new Random();
        randomNumber = randomGenerator.nextInt(21);
    }
}

@@ -25,26 +25,57 @@
 dic.
-higherorlow
+sounddemo;%0D%0A%0D%0Aimport android.media.MediaPlay
 er;%0D%0A
-%0D%0A
 impo
@@ -177,99 +177,8 @@
 ew;%0D
-%0Aimport android.widget.EditText;%0D%0Aimport android.widget.Toast;%0D%0A%0D%0Aimport java.util.Random;%0D
 %0A%0D%0Ap
@@ -235,28 +235,33 @@
  %7B%0D%0A
-%0D%0A
     
-int randomNumb
+MediaPlayer mediaPlay
 er;%0D
@@ -283,18 +283,17 @@
 oid 
-checkGuess
+playAudio
 (Vie
@@ -302,26 +302,24 @@
 view)%7B%0D%0A
-%0D%0A
         
 EditText
@@ -314,80 +314,34 @@
     
-EditText guessedNumber = (EditText) findViewById(R.id.editNumber
+mediaPlayer.start(
 );%0D%0A    
     
@@ -340,1084 +340,196 @@
     
-    if(!(guessedNumber.getText().toString().isEmpty()))%7B%0D%0A%0D%0A        String guessedNumberString = guessedNumber.getText().toString();%0D%0A%0D%0A        int guessedNumberInt = Integer.parseInt(guessedNumberString);%0D%0A        String message = %22%22;%0D%0A%0D%0A        if (guessedNumberInt == (int)guessedNumberInt) %7B%0D%0A%0D%0A            if (guessedNumberInt %3E randomNumber) %7B%0D%0A                message = %22High!%22;%0D%0A            %7D else if (guessedNumberInt %3C randomNumber) %7B%0D%0A                message = %22Low%22;%0D%0A            %7D else if (guessedNumberInt == randomNumber) %7B%0D%0A                message = %22Correct%22;%0D%0A            %7D else %7B%0D%0A                message = %22No number was given!%22;%0D%0A            %7D%0D%0A            System.out.println(%22Random Number: %22 + randomNumber);%0D%0A            Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();%0D%0A%0D%0A        %7D else%7B%0D%0A            Toast.makeText(getApplicationContext(), %22Not a number%22, Toast.LENGTH_LONG).show();%0D%0A        %7D%0D%0A        %7D else %7B%0D%0A            Toast.makeText(getApplicationContext(), %22You did not type!%22, Toast.LENGTH_LONG).show();%0D%0A        %7D
+%7D%0D%0A%0D%0A    public void pauseAudio(View view)%7B%0D%0A        mediaPlayer.pause();%0D%0A    %7D%0D%0A%0D%0A    public void stopAudio(View view)%7B%0D%0A        mediaPlayer.stop();%0D%0A         mediaPlayer.prepareAsync();
 %0D%0A  
@@ -716,98 +716,59 @@
     
-Random randomGenerator  = new Random();%0D%0A        randomNumber = randomGenerator.nextInt(21
+mediaPlayer = MediaPlayer.create(this, R.raw.dukkho
 );%0D%0A
@@ -775,10 +775,8 @@
     %7D%0D%0A%7D
-%0D%0A

Add files via upload