Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum Folder {
- case hidden
- case opened
- }
- struct File {
- private var content: String
- private var access: Folder
- private var password: String?
- init(content: String, access: Folder, password: String?) {
- self.content = content
- self.access = access
- self.password = password
- }
- private var accessToFolder: Folder {
- let folderType: Folder
- switch access {
- case .hidden:
- folderType = .hidden
- default:
- folderType = .opened
- }
- return folderType
- }
- func showContent() -> String {
- let resultOfProcessing: String
- switch accessToFolder {
- case .opened:
- if self.password == nil {
- resultOfProcessing = self.content
- } else {
- resultOfProcessing = "Can't show. We don't know password"
- }
- case .hidden:
- resultOfProcessing = "No access. Folder is hidden"
- }
- return resultOfProcessing
- }
- }
- var movie = File(content: "Columbia pictures presents....", access: .opened, password: nil)
- print(movie.showContent())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement