//
//  Job
//
//  Created by MobilePioneers on 21/08/2015.
//  Copyright (c) 2015 MobilePioneers. All rights reserved.
//

enum Education: Int {
    
    case None
    case HighSchool
    case MBO
    case HBO
    case University
    case PHD
    case BeyondPHD
    
}

extension Education: Comparable { }

func <<T: RawRepresentable where T.RawValue: Comparable>(lhs: T, rhs: T) -> Bool {
    return lhs.rawValue < rhs.rawValue
}

class Applicant {
    
    var name: String!
    var yearsOfExperience: Float!
    var levelOfEducation: Education!
    var skills: Set<String>!
    var interests: Set<String>!
    var isIntern: Bool!
    
}

class Developer {
    
    var skillsWeLike: Set<String>!
    var interestsWeLike: Set<String>!
    var applicant: Applicant!
    
    init(applicant: Applicant) {
        self.applicant = applicant
        if self.applicant.isIntern == true {
            
            self.skillsWeLike = [
                "Can use stackoverflow.com",
                "Familiar with Objective-C, Swift and iOS SDK",
                "Teamplayer but able to work independently",
                "Object oriented programming",
                "Follow code styles",
                "Know what CamelCase is" ]
            
        } else {
            
            self.skillsWeLike = [
                "Pragmatic",
                "Thorough understanding of Objective-C, Swift and iOS SDK",
                "Teamplayer but able to work independently",
                "Git, SVN, Mercurical (we use Git)",
                "XML, json, webservices api's",
                "At least one published app",
                "Knowledge and experience with other programming languages would be great!" ]
            
        }
        
        self.interestsWeLike =  [
            "Affinity with mobile apps",
            "Gadget freak",
            "Eye for detail",
            "Curious mind, likes to learn new stuff!" ]
        
        let areWeInterested = self.testApplicant()
        
        if areWeInterested {
            print("Awesome! Dear \(applicant.name) it looks like we could be a match! Please email Robin Heukels at vacatures@mobilepioneers.com")
        } else {
            print("Bailing, sorry you're not for us...")
        }
        
    }
    
    func testApplicant() -> Bool {
        
        var weLike: Bool = false
        
        if (self.applicant.yearsOfExperience >= 2.0 && self.applicant.levelOfEducation >= .HBO) || self.applicant.isIntern == true {
            
            let skillsMatch: Bool = applicant.skills.intersect(self.skillsWeLike).count > 0
            
            if skillsMatch {
                weLike = applicant.interests.intersect(self.interestsWeLike).count > 0
            }
            
        }
        
        return weLike
        
    }
    
}