Skip to content

Instantly share code, notes, and snippets.

@jgn
Created March 6, 2014 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgn/9379634 to your computer and use it in GitHub Desktop.
Save jgn/9379634 to your computer and use it in GitHub Desktop.
class HalfAdder
attr_reader :sum, :carry
def initialize(augend, addend, logger)
@augend, @addend, @logger = augend, addend, logger
end
def compute
@carry = @augend & @addend
@sum = @augend ^ @addend
@logger.info "augend: #{@augend}"
@logger.info "addend: #{@addend}"
@logger.info "carry: #{@carry}"
@logger.info "sum: #{@sum}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment