protocol Strategy {
    func execute()
}
// Concrete Strategy
class CarRoute: Strategy {
    func execute() {
        print("자동차 경로 찾기 완료!\\n")
    }
}

// Concrete Strategy
class WalkRoute: Strategy {
    func execute() {
        print("도보 경로 찾기 완료!\\n")
    }
}

// Concrete Strategy
class BikeRoute: Strategy {
    func execute() {
        print("자전거 경로 찾기 완료!\\n")
    }
}
class Navigation {
    private var routeAlgorithm: Strategy?
    
    func execute() {
        self.routeAlgorithm?.execute()
    }
    
    func assign(strategy: Strategy) {
        self.routeAlgorithm = strategy
    }
}
let navigation = Navigation()
navigation.assign(strategy: CarRoute())
navigation.execute()

navigation.assign(strategy: WalkRoute())
navigation.execute()

navigation.assign(strategy: BikeRoute())
navigation.execute()

Untitled