首页 > 解决方案 > Kotlin 中学班建设者

问题描述

我有一些导致错误的代码。我似乎找不到问题,因为我一直在关注一本书。代码如下:

class Player (_name: String,
               var healthPoints: Int,
               val isBlessed: Boolean,
               private val isImmortal: Boolean) {

    var name = _name
        get() = field.capitalize()
        private set(value) {
            field = value.trim()
        }

    constructor(name: String) : this(name,
                healthPoints = 100,
                isBlesed = true,
                isImmortal = false)

我不明白这个关键字正在创建的错误如下:

Error:(14, 33) Kotlin: None of the following functions can be called with the arguments supplied:   
public constructor Player(name: String) defined in com.bignerdranch.nyethack.Player    
public constructor Player(_name: String, healthPoints: Int, isBlessed: Boolean, isImmortal: Boolean) defined in com.bignerdranch.nyethack.Player

标签: kotlinconstructor

解决方案


你这个词有错别字isBlesed


推荐阅读