-
-
Save fitomad/d6e04784f77cef8b1b57a3df04ac8915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Database: CareTaker | |
{ | |
/// Este `Array` hace las veces de base de datos | |
private var items: [Memento] | |
/// Todos los *snapshots* disponibles | |
public var mementos: [Memento] | |
{ | |
return items | |
} | |
/** | |
Creamos una base de datos vacía | |
*/ | |
public init() | |
{ | |
self.items = [Memento]() | |
} | |
/** | |
Guarda un *snapshot* | |
*/ | |
public func saveMemento(_ memento: Memento) -> Void | |
{ | |
self.items.append(memento) | |
} | |
/** | |
Recupera el último *snapshot* | |
*/ | |
public func lastMemento() -> Memento? | |
{ | |
return items.last | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment