Skip to content

Commit dc64fe4

Browse files
Refactored squaring into a separate class
1 parent 32c2737 commit dc64fe4

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/Main.groovy

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1+
import Square
2+
13
def name = "Matthew"
4+
int programmingPoints = 10
25

36
println "Hello ${name}"
4-
5-
int programmingPoints = 10
67
println "${name} has at least ${programmingPoints} programming points."
7-
8-
println "${programmingPoints} squared is ${square(programmingPoints)}"
9-
10-
int square(int base) {
11-
base * base
12-
}
8+
println "${programmingPoints} squared is ${Square.square(programmingPoints)}"

src/Square.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
static int square(int base) {
2+
base * base
3+
}

0 commit comments

Comments
 (0)