Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.5 kB
2
Indexable
Never
fun main(args: Array<String>) {

    var car_type = ArrayList<String>()
    var car_model = ArrayList<String>()
    var car_years = ArrayList<String>()
    var price = ArrayList<Double>()
    var Knum = ArrayList<Int>()
    var vehical_se = ArrayList<String>()
    var x = 1
    var i = 0

    val car_type_reg = Regex("([a-zA-Z]{2,25})")
    val car_years_reg = Regex("[0-9]{2,4}")
    while (x != 0) {
        var caryear = ""
        var cartype=""

        println("Enter type of car" + (i + 1) + ":")
        while (car_type_reg.matches(cartype) == false) {
            cartype = readLine()!!
            if (!car_type_reg.matches(cartype))
                println("!! please Enter character !!")
        }
        car_type.add(cartype)

        println("Enter model of car" + (i + 1) + ":")
        car_model.add(readLine()!!.toString())


         println("Enter years of car" + (i + 1)+":")
        while (car_years_reg.matches(caryear) == false) {
            caryear = readLine()!!
            if (!car_years_reg.matches(caryear))
                println("Enter just four number !!")
        }
car_years.add(caryear)

        println("Enter Price" + (i + 1) + ":")
        price.add(readLine()!!.toDouble())

        println("Enter How many kilometers have you covered" + (i + 1) + ":")
        Knum.add(readLine()!!.toInt())

        var veh_hash = hashMapOf<Int, String>()
        print("Enter the vehical number" + (i + 1) + ":")
        veh_hash.put(readLine()!!.toInt(), readLine()!!)

            }
    var coun=1
    var stop='r'
    do {
        var option = readLine()!!.toInt()
        when (option) {
            1 -> for (i in 0 until car_years.size) {
                println("the full data of CAR no :$coun\n" + car_type[i]
                        + " " + car_model[i] + " " + car_years[i] + " " + knum[i] + " " + vehical_se[i] + "\n")
                println("----------------------------------------------------------")
                coun++
            }
            2 -> {
                        println("What is vehical serial look for :$coun\n")
                var s= readLine()!!.toInt()
                veh_hash.get(readLine()!!.toInt(), readLine()!!)
                    println(s)
            }
           
        }
        println("Do you want to make another enquiry ?\nY/N")
        stop= readLine()!!.single()


    } while (stop == 'Y' || stop=='y')
}

}