Skip to content

Instantly share code, notes, and snippets.

@fitomad
Created April 23, 2019 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitomad/d6e04784f77cef8b1b57a3df04ac8915 to your computer and use it in GitHub Desktop.
Save fitomad/d6e04784f77cef8b1b57a3df04ac8915 to your computer and use it in GitHub Desktop.
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