Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Word
- constructor: (@word) ->
- getWord: ->
- @word.trim()
- class WordGroup
- constructor: ->
- @end = []
- print: (cb) ->
- words = @process @end
- if typeof cb is 'function'
- cb words
- else
- console.log(words)
- return this
- class Sentence extends WordGroup
- addWord: (word) ->
- word = new Word word if typeof word is 'string'
- word = word.getWord?()
- @end.push word if word
- return this
- process: ->
- words = @end.join ' '
- words[0].toUpperCase() + words.slice(1) + '.'
- class Paragraph extends WordGroup
- addSentence: (sentence) ->
- sentence.print (string) =>
- @end.push string if string
- return this
- process: ->
- @end.join ' '
Add Comment
Please, Sign In to add comment