Created
March 31, 2018 08:34
-
-
Save iamcrypticcoder/f0c141724144c4aeccd14144d56bca45 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 | |
class User { | |
var posts: [Post] = [Post]() | |
func addPost(_ post: Post) -> Void { | |
posts.append(post) | |
} | |
func analyzePosts(_ strategy: PostAnalyzeStrategy) -> Void { | |
strategy.analyze(self.posts) | |
} | |
} | |
class Post { | |
var text: String? | |
var likeCount: Int = 0 | |
var sadCount: Int = 0 | |
var laughCount: Int = 0 | |
init(_ text: String) { | |
self.text = text | |
} | |
convenience init(_ text: String, _ likeCount: Int, _ sadCount: Int, _ laughCount: Int) { | |
self.init(text) | |
self.likeCount = likeCount | |
self.sadCount = sadCount | |
self.laughCount = laughCount | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment