Thuta Learning
ရှာဖွေရန်
AdvancedProgrammingbeginner

Mini Project

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

ဒီ mini project မှာ Kotlin အခြေခံတွေကိုပေါင်းပြီး simple course enrollment summary တစ်ခုရေးပါမယ်။ Data class, list, function, filter, map, string template တွေကို တစ်နေရာတည်းမှာ လက်တွေ့အသုံးချကြည့်နိုင်ပါတယ်။ Real app တစ်ခုမှာ course list, enrolled student list, active user list စတာတွေကို process လုပ်တဲ့ idea နဲ့ဆင်တူပါတယ်။

kotlin
data class Course(val title: String, val price: Int, val enrolled: Boolean)

fun calculateTotal(courses: List<Course>): Int {
    return courses
        .filter { it.enrolled }
        .map { it.price }
        .sum()
}

fun main() {
    val courses = listOf(
        Course("Kotlin Basics", 30000, true),
        Course("Android UI", 45000, false),
        Course("Backend API", 50000, true)
    )

    val enrolledCourses = courses.filter { it.enrolled }
    val titles = enrolledCourses.map { it.title }
    val total = calculateTotal(courses)

    println("Enrolled courses: $titles")
    println("Total price: $total MMK")
}
You should see
Enrolled courses: [Kotlin Basics, Backend API] Total price: 80000 MMK

အနှစ်ချုပ်

Mini project က Kotlin foundation တွေကို real-world data processing flow တစ်ခုအဖြစ်စုစည်းပြထားပါတယ်။

နောက်တစ်ဆင့်

ဒီအဆင့်ပြီးရင် Kotlin coroutines, Android Jetpack Compose, Spring Boot with Kotlin တို့ကို ဆက်လေ့လာနိုင်ပါတယ်။

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • sum() သုံးဖို့ list item တွေက number ဖြစ်ရပါမယ်။ Course object list ကိုတိုက်ရိုက် sum() ခေါ်လို့မရပါ။