Created
May 3, 2022 14:54
-
-
Save Sal7one/681a6311d0abb1dcf44c2e7a6d26408e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class MainActivity : AppCompatActivity() { | |
private val secretUserNum = Random().nextInt(100) + 1 | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
findViewById<TextView>(R.id.actualPass).text = "Actual pass $secretUserNum " | |
findViewById<Button>(R.id.decryptBtn).setOnClickListener { | |
val userEntry = findViewById<EditText>(R.id.passwordEt).text.toString().toInt() | |
if (secretUserNum == userEntry) | |
findViewById<TextView>(R.id.mainText).text = "Access Granted " | |
else | |
Toast.makeText(this, "Bad Password!", Toast.LENGTH_LONG).show() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Article - Medium.com