What’s missing from this code?

Asked

Viewed 74 times

0

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 Ference: Task val minhaTarefa = Task("Daniel", "Programming", 10, "30 September") ^

  • 2

    Good question, you can tell us why you think something is missing?

  • Please rephrase the question so we know what your question is.

  • The following error appears: source.kt:4:23: error: unresolved Reference: Task val minhaTarefa = Task("Daniel", "Programming", 10, "September 30") ^

  • But I don’t know what I need to do to fix it, you can help me?

  • 1

    Apparently there is no class called Tarefa.

  • The class name is wrong, try as val minhaTarefa = TarefaDeCasa("Daniel", "Programação", 10, "30 de Setembro")

  • 1

    That’s exactly what it was!!! Thank you guys so much! I managed to make the code!

Show 2 more comments

2 answers

6


There is no class called 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 in Try.kotlinlang.org

3

So it works, I think it was just typo 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}")
    }
}

Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.