1
我是新的Swift,當我想要構建此代碼時遇到問題。 「表達太複雜,無法在合理的時間內解決;考慮將表達分解爲不同的子表達式」。打印()的長參數會產生錯誤「表達式太複雜而無法解決」
我想我的方法來管理屬性,當我想打印的東西是錯誤的,但我沒有找到原因。
class Personne{
var name : String
var forename : String
init(name : String, forename:String) {
self.name = name
self.forename = forename
}
}
class UnilStudent : Personne{
var id : Int
var section : String
init(name :String, forename:String, id:Int, section:String) {
self.section = section
self.id = id
super.init(name:name, forename:forename)
}
func affiche() {
print("Unil student N°" + \(self.id) + " : " + \(self.name) + \(self.forename) + "\n" + \(self.section + "\n")}
}
class Assistants : UnilStudent{
var assistantship : String
init(name :String, forename:String, id:Int, section:String, assistantship : String){
self.assistantship = assistantship
super.init(name :name, forename:forename, id:id, section:section)
}
override func affiche() {
super.affiche()
print("Unil student N°" + \(self.id) + " : " + \(self.name) + " " + \(self.forename) + "\n from " + \(self.section) + "is a student assistant for" + \(self.assistantship) + "\n")}
func printid(){
print("L'id de " + \(self.name) + " " + \(self.forename) + " est " + \(self.id))
}
}
let Adrien = Assistants(name : "BOB", forename : "BOBBY", id : 12000000, section : "FDCA", assistantship : "ACT")
let Alice = UnilStudent(name: "Hapoka", forename : "Alice", id : 17000000, section : "HEC")
print(Adrien)