What's missing in this code? [closed]

1
fun main(args: Array<String>) {
    val minhaTarefa = Tarefa("Daniel", "Programação", 10, "30 de Setembro")

    minhaTarefa.entregar()
}
   class TarefaDeCasa(
     var nomeDoAluno: String,
     var nomeDaMateria: String,
     var nota: Int,
       var dataDeEntrega: String) {

   fun entregar() {
        println("o aluno ${nomeDoAluno} entregou a tarefa do dia ${dataDeEntrega} e recebeu a nota ${nota}")
        }
  }
  

source.kt: 4: 23: error: unresolved reference: Task val myTask = Task ("Daniel", "Programming", 10, "September 30") ^

    
asked by anonymous 09.10.2017 / 20:28

2 answers

6

There is no class named Tarefa , the class name is TarefaDeCasa

fun main(args: Array<String>) {
    val minhaTarefa = TarefaDeCasa("Daniel", "Programação", 10, "30 de Setembro")

    minhaTarefa.entregar()
}

class TarefaDeCasa(
    var nomeDoAluno: String,
    var nomeDaMateria: String,
    var nota: Int,
    var dataDeEntrega: String) {

    fun entregar() {
        println("o aluno ${nomeDoAluno} entregou a tarefa do dia ${dataDeEntrega} e recebeu a nota ${nota}")
    }
}

See working at try.kotlinlang.org

    
09.10.2017 / 20:38
3

So it works, I think it was just typing error since the created class calls TarefaDeCasa and the call to instantiate was Tarefa :

fun main(args: Array<String>) {
    val minhaTarefa = TarefaDeCasa("Daniel", "Programação", 10, "30 de Setembro")
    minhaTarefa.entregar()
}
class TarefaDeCasa(
    var nomeDoAluno: String,
    var nomeDaMateria: String,
    var nota: Int,
    var dataDeEntrega: String) {

    fun entregar() {
        println("o aluno ${nomeDoAluno} entregou a tarefa do dia ${dataDeEntrega} e recebeu a nota ${nota}")
    }
}

See running on ideone . And in Coding Ground . Also put it in GitHub for future reference .

    
09.10.2017 / 20:39