class Student {
let name: String
init(name: String) {
self.name = name
}
var scoreCard: ScoreCard?{
didSet{
print("\(name) got \(scoreCard!.marks) marks in this exam")
}
}
}
class ScoreCard {
let marks: Float
init(marks: Float) {
self.marks = marks
}
var student: Student?{
didSet{
print("\(marks) for \(student!.name) in this exam")
}
}
}
var student: Student?
var score:ScoreCard?
student = Student(name: "Albert Einstein")
score = ScoreCard(marks: 80)
student!.scoreCard = score
score!.student = student
student = nil
score = nil
All Replies
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.