Skip to content

Commit da5ebf4

Browse files
committed
Added clockhands solution
1 parent 87d2821 commit da5ebf4

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

eiffel/clockhands.e

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
class
2+
CLOCKHANDS
3+
4+
create
5+
make
6+
7+
feature
8+
9+
make
10+
local
11+
t: INTEGER
12+
h: INTEGER
13+
m: INTEGER
14+
s: INTEGER
15+
do
16+
across 0 |..| 10 as i loop
17+
t := (43200 * i + 21600) // 11
18+
h := t // 3600
19+
m := t // 60 \\ 60
20+
s := t \\ 60
21+
if h = 0 then
22+
h := 12
23+
end
24+
print (pad (h))
25+
print (":")
26+
print (pad (m))
27+
print (":")
28+
print (pad (s))
29+
print ("%N")
30+
end
31+
end
32+
33+
feature
34+
35+
pad (n: INTEGER): STRING
36+
do
37+
if n < 10 then
38+
Result := "0" + n.out
39+
else
40+
Result := n.out
41+
end
42+
end
43+
end

eiffel/test.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ function Assert-MatchTests {
99
}
1010

1111
$Error.clear()
12+
ec "$PSScriptRoot\clockhands.e" && . "$PSScriptRoot\clockhands.exe" |
13+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
14+
Assert-MatchTests &&
1215
ec "$PSScriptRoot\hello.e" && . "$PSScriptRoot\hello.exe" &&
1316
ec "$PSScriptRoot\triple.e" && . "$PSScriptRoot\triple.exe" |
1417
Compare-Object (Get-Content "$PSScriptRoot\..\test\triple_expected") |

0 commit comments

Comments
 (0)