Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.6 kB
4
Indexable
Never
import java.text.DecimalFormat
fun main(args: Array<String>) {
    var car_type=arrayListOf<String>()
    var car_modle = arrayListOf<String>()
    var car_year = arrayListOf<String>()
    var car_price =arrayListOf<Double>()
    var car_kilomter = arrayListOf<String>()
    var car_body_number = hashMapOf<Int ,String >()
    val year_temp = Regex("\\d{4}")
    val kilomter_temp = Regex("[0-9]*")
    var name_temp = Regex("[A-Za-z]*")
    var test_name=""
    var test_kilomter=""
    var test_year=""

    var x =-1
    var y =-1
    var i=0;
    var z= 0;
    while (x!= 0)
    {
        println("Enter car name : ")
        test_name = readLine()!!.toString()
         while (!name_temp.matches(test_name))
         {

             println("wrong car name, please Enter car name : ")
             test_name = readLine()!!.toString()

         }
        car_type.add(test_name)
        //----------
        println("Enter car modle : ")
        car_modle.add(readLine()!!.toString())
        //------
        println("Enter car year : ")
        test_year = readLine()!!.toString()

        while (!year_temp.matches(test_year))
        {

            println("wrong car year, please Enter car year : ")
            test_year = readLine()!!.toString()

        }
        car_year.add(test_year)
        //------
        println("Enter car prise : ")
        car_price.add(readLine()!!.toDouble())
        //------
        println("Enter car kilomters : ")
        test_kilomter = readLine()!!.toString()
        while (!kilomter_temp.matches(test_kilomter))
        {

            println("wrong car kilomters, please Enter car kilomters : ")
            test_kilomter = readLine()!!.toString()

        }
        car_kilomter.add(test_kilomter)
        //------
        println("Enter car body number : ")
        car_body_number.put(i,readLine()!!.toString())

        println("if you want to exit prise 0 , if you want to add a new car enter eny number  : ")
        x = readLine()!!.toInt()
        i++



    }
    println("---------")
    y = readLine()!!.toInt()
    when(y)
    {
        1->{
            for(z in car_type.indices)
            {
                println(car_type[z]+" "+car_modle[z]+" "+car_year[z]+" "+car_price[z]+" "+car_kilomter[z]+" "+car_body_number.getValue(z))
            }
        }
        2->{}
        3->{}
        4->{}
        5->{}
        6->{}
        7->{}
        8->{}
        0->{}
        else ->{}


    }



}