This Android app is a simple dice roller built with Kotlin. With a tap of the “Roll” button, it randomly generates numbers for two dice, updates their images, shows the results, and displays the total steps in a Toast message.

تفاصيل العمل

Type of Work

This is a native Android game app built with Kotlin that simulates rolling two dice. It focuses on UI interaction and random number generation, giving a simple but fun dice-rolling experience.

Features

Dual Dice Roll

Rolls two dice simultaneously and shows random results (1–6) for each.

Dynamic Images

Dice images change instantly based on the rolled numbers.

Result Display

Displays the outcome of each die in a TextView.

Move Notification

Toast message shows the total steps to move (sum of both dice).

Responsive Layout

Edge-to-edge design for a clean look on different screen sizes.

Implementation Details

UI Components:

Two ImageViews for dice, a Button to trigger rolling, and a TextView to show results.

Random Number Generation:

(1..6).random() generates dice values each time the button is pressed.

Image Mapping:

when expressions map each number to the corresponding dice drawable (R.drawable.dice_1 … dice_6).

Event Handling:

btn.setOnClickListener updates dice images, displays text results, and shows a Toast with the total steps.

Lifecycle Awareness:

Standard lifecycle methods are present (commented) for potential logging or state management.

Edge-to-Edge UI:

enableEdgeToEdge() and ViewCompat.setOnApplyWindowInsetsListener adjust padding for system bars.

ملفات مرفقة

بطاقة العمل

اسم المستقل
عدد الإعجابات
0
عدد المشاهدات
1
تاريخ الإضافة
تاريخ الإنجاز
المهارات