Created
August 6, 2016 00:39
-
-
Save keitheous/95728bda8d9b5d626c4590c0cd29623a 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
require 'pry' | |
class Squares | |
def initialize(num) | |
@num = num | |
end | |
def square_of_sum | |
square_of_sum = 0 | |
(1..@num).each do |i| | |
square_of_sum += i | |
end | |
@square_of_sum = square_of_sum**2 | |
end | |
def sum_of_squares | |
sum_of_squares = 0 | |
(1..@num).each do |i| | |
sum_of_squares += i**2 | |
end | |
@sum_of_squares = sum_of_squares | |
end | |
def difference | |
difference = @square_of_sum - @sum_of_squares | |
#? what do i do here to call second & third function first before this function | |
end | |
end | |
# Squares.new(5).square_of_sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def test_difference_of_squares_0
# skip
assert_equal 0, Squares.new(0).difference
end