swift5.0 结构体

2021-07-15  本文已影响0人  marlonxlj
struct Student
{
    var name = "unknow"
    var age = 0
    var score = 0.0
    var isPass = false

    static let schollName = "雷迪森"
    
    init(name:String,age:Int,score:Double) {
        self.name = name
        self.age = age
        self.score = score
        
        if self.score < 60 {
            self.isPass = false
        }else{
            self.isPass = true
        }
    }
    
    func fetch() -> String
    {
        return self.name
        
    }
}

var a = Student(name: "嘻嘻嘻", age: 20, score: 90)

print(a)
print(Student.schollName)

上一篇下一篇

猜你喜欢

热点阅读