forked from tjhickey724/OctaveBat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_alarm_clock.m
executable file
·78 lines (71 loc) · 1.42 KB
/
test_alarm_clock.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function count=test_alarm_clock()
% test_alarm_clock tests function alarm_clock and print out the result returned by alarm_clock and also prints out number of results failed the test
% seife kassahun
% Feb 2011
ans=0
test1=alarm_clock(1,'False')
if !strcmp(test1,'7:00')
ans=ans+1;
end
test2=alarm_clock(5,'False')
if !strcmp(test2,'7:00')
ans=ans+1;
end
test3=alarm_clock(0,'False')
if !strcmp(test3,'10:00')
ans=ans+1;
end
test4=alarm_clock(6,'False')
if !strcmp(test4,'10:00')
ans=ans+1;
end
test5=alarm_clock(0,'True')
if !strcmp(test5,'off')
ans=ans+1;
end
test6=alarm_clock(6,'True')
if !strcmp(test6,'off')
ans=ans+1;
end
fprintf"No of failed results are ",ans
endfunction% for function
function y=alarm_clock(day,vacation)
%alarm_clock set the alarm based on the day of the week including vacation day
% Seife Kassahun
%Feb 2011
if strcmp(vacation,"True")
switch day
case 0
y="off";
case 1
y="10:00";
case 2
y="10:00";
case 3
y="10:00";
case 4
y="10:00";
case 5
y="10:00";
otherwise
y="off";
endswitch
else
switch day
case 0
y="10:00";
case 1
y="7:00";
case 2
y="7:00";
case 3
y="7:00";
case 4
y="7:00";
case 5
y="7:00";
otherwise
y="10:00";
endswitch
endif
endfunction