-
-
Save fitomad/5779be34be0176d0da46c6f27388d19d 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
import Foundation | |
public enum Departamento | |
{ | |
case it | |
case humanResources | |
case financial | |
} | |
public struct Usuario | |
{ | |
/// Nombre | |
public private(set) var nombre: String | |
/// Departamento en el que trabaja | |
public private(set) var departamento: Departamento | |
/// Años trabajando aquí | |
public private(set) var antiguedad: Int | |
/// ¿Es un empleado veterano? | |
public var isElder: Bool | |
{ | |
return self.antiguedad >= 15 | |
} | |
/** | |
Nuevo usuario con su nombre, departamento y antiguedad | |
*/ | |
public init(named name: String, worksIn department: Departamento, for years: Int) | |
{ | |
self.nombre = name | |
self.departamento = department | |
self.antiguedad = years | |
} | |
} | |
// | |
// Creamos algunos empleados... | |
// | |
let bunchOfUsers = [ | |
Usuario(named: "Adolfo", worksIn: .it, for: 17), | |
Usuario(named: "Maribel", worksIn: .it, for: 19), | |
Usuario(named: "Natalia", worksIn: .humanResources, for: 8), | |
Usuario(named: "Manuel", worksIn: .financial, for: 14), | |
Usuario(named: "Erika", worksIn: .it, for: 18) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment