Commit 9297c13a authored by Ilya Prokhorov's avatar Ilya Prokhorov

Print for private title field

parent 19e60ba6
......@@ -23,7 +23,7 @@ class Memento<T> {
class MusicTrack: Originator {
private(set) var title: String
private var title: String
init(title: String) {
self.title = title
......@@ -42,12 +42,16 @@ class MusicTrack: Originator {
func randomizeTitle() {
title = "\(Int.random(in: 1...100))"
}
func printTitle() {
print(title)
}
}
let musicTrack = MusicTrack(title: "Procractinallica")
let memento = musicTrack.memento()
debugPrint(musicTrack.title)
musicTrack.printTitle()
musicTrack.randomizeTitle()
debugPrint(musicTrack.title)
musicTrack.printTitle()
musicTrack.apply(memento: memento)
debugPrint(musicTrack.title)
musicTrack.printTitle()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment