我是Kotlin的新手,我嘗試將一個小型Java項目重新改爲這種新語言。我使用MongoDB的在我的項目,我有一個類,例如: class PlayerEntity {
constructor() {} //for mongodb to create an instance
constructor(id: ObjectId, name: String) { //used in
class Car(val miles:Int,val year:Int)
val myCar = new Car(100,2016);
println(myCar.miles)
在此示例中myCar.miles爲我提供了英里的值。但是我想定義明確的getter來處理myCar的miles屬性。這個怎麼做?
我基本上被要求獲取字符串的Unicode值,將其乘以10%並添加對象當前所具有的任何級別。這是令人沮喪的,因爲事實證明,我已經包括代碼的邏輯,但我仍然得到一個錯誤,說:期望:< 0>但是:< 8>。任何建議,也許這只是我必須在邏輯中做出的細微差別,儘管我相當確定它是正確的。 。注意到getLevel方法的,因爲那是錯誤的 public class PouchCreature implements