Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.7 kB
2
Indexable
Never
fun main(args:Array<String>) {
  var chassisnum : HashMap<Int, String> = HashMap()
  var cartyep = arrayListOf<String>()
  var carmodel = arrayListOf<String>()
  var cardate = arrayListOf<Int>()
  var carprice = arrayListOf<Double>()
  var carKelom = arrayListOf<Int>()

  var carKelom_RE = Regex("([0-9]{0,9})")
  var cardate_RE = Regex("([0-9]{4})")
  var cartyep_RE = Regex("([a-zA-Z]{1,30})")

  var Stop = 1
  var i = 1
  while (Stop!=0){
      var carname =""
      var kilom = -1
      var date = -1

      print("Enter the car type")
    while (cartyep_RE.matches(carname) == false){
      carname = readLine()!!.toString()
      if (!cartyep_RE.matches(carname))
        print("Enter agin")

    }
    cartyep.add(readLine()!!.toString())

    print("Enter the model of car : ")
    carmodel.add(readLine()!!.toString())

    print("Enter the date of car :")
    while (date < 0) {
      date = readLine()!!.toInt()
      if (date < 0)
        print("Enter agin")
    }
    cardate.add(date)

    print("Enter the car price")
    carprice.add(readLine()!!.toDouble())

    print("Enter the kilo meter of car : ")
    while (kilom<0){
      kilom = readLine()!!.toInt()
      if (kilom<0)
        print("Enter agin")
    }
    carKelom.add(kilom)
    print("Enter the chassis number of car and name the car ")
    chassisnum.put(readLine()!!.toInt(), readLine()!!.toString())

    println("Enter 0 TO stop \nand any key to continue")
    Stop = readLine()!!.toInt()
    i++

  }
  print("Enter 1 to show all car")
  var op = readLine()!!.toInt()
  when(op){
    1-> for (i in 0 until cartyep.size ){
      println("Name car "+cartyep[i])
    }
    2->
  }


}