Skip to content

Commit

Permalink
fix: get rid of dependency bug in project
Browse files Browse the repository at this point in the history
The last change in the project introduced an a
refactor that lead to the new bug tht crashed the
program. With this, the program should run once
again smoothly as before.
  • Loading branch information
Robert-Walker0 committed Nov 19, 2024
1 parent 7524442 commit 7bcd126
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lua/calculations.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "math"
require "input_utils"
local input_utils = require("input_utils")

local Triangle = {}
Triangle.__index = Triangle
Expand Down Expand Up @@ -29,7 +29,7 @@ end

function Triangle:getArea()
local halved_perimeter = self:getPerimeter()/2
return math.sqrt(halved_perimeter * (halved_perimeter - self.side_one) * (halved_perimeter - self.side_two) * (halved_perimeter - self.side_three))
return math.sqrt(halved_perimeter * (halved_perimeter - self.sides[1]) * (halved_perimeter - self.sides[2]) * (halved_perimeter - self.sides[3]))
end

function Triangle:isTriangle()
Expand Down
8 changes: 6 additions & 2 deletions src/lua/input_utils.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "io"

function getInput()
local utils = {}

function utils.getInput()
local value = io.read()
local results = tonumber(value)
if results == nil then
Expand All @@ -9,4 +11,6 @@ function getInput()
elseif type(results) == "number" then
return results
end
end
end

return utils

0 comments on commit 7bcd126

Please sign in to comment.