Skip to content

Instantly share code, notes, and snippets.

@iamcrypticcoder
Created March 31, 2018 08:34
Show Gist options
  • Save iamcrypticcoder/f0c141724144c4aeccd14144d56bca45 to your computer and use it in GitHub Desktop.
Save iamcrypticcoder/f0c141724144c4aeccd14144d56bca45 to your computer and use it in GitHub Desktop.
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