1 function charge_calc(checkin_date,checkout_time,late_checkout_time,room_rate){
2 today = date();
3 expected_checkout_time = 12pm;
4 latest_checkout_time = 6pm;
5 no_of_nights = today-checkin_date;
6 if(late_checkout_time<>"None"){
7 if(late_checkout_time>expected_checkout_time)and(late_checkout_time<=latest_checkout_time){
8 expected_checkout_time = late_checkout_time;
9 }
10 }
11 if(checkout_time > expected_checkout_time) or (checkin_date == today){
12 no_of_nights = no_of_nights + 1;
13 }
14 charge = no_of_nights * room_rates;
15 return charge
16 }
| Line | Category | ||
| Defination | c-use | p-use | |
| 1 | checkin_date checkout_time late_checkout_time room_rate |
||
| 2 | today | ||
| 3 | expected_checkout_time | ||
| 4 | latest_checkout_time | ||
| 5 | no_of_nights | today checkin_date |
|
| 6 | late_checkout_time | ||
| 7 | late_checkout_time expected_checkout_time latest_checkout_time |
||
| 8 | late_checkout_time |
||
| 11 | checkout_time exptected_checkout_time checkin_date today |
||
| 12 | no_of_nights | ||
| 14 | charge | no_of_nights room_rate |
|
du-pair |
Variable |
|
c-use
|
p-use |
|
1->5 |
checkin_date | |
1->11 |
checkin_date | |
1->11 |
checkout_time | |
1->6 |
late_checkout_time | |
1->7 |
late_checkout_time | |
1->8 |
late_checkout_time | |
1->14 |
room_rate | |
2->5 |
today | |
2->11 |
today | |
3->7 |
expected_checkout_time | |
3->8 |
expected_checkout_time | |
3->11 |
expected_checkout_time | |
4->7 |
latest_checkout_time | |
5->12 |
no_of_nights | |
5->14 |
no_of_nights | |
du-pair |
Variable |
Path |
1->5 |
checkin_date | 1-2-3-4-5 |
1->11 |
checkout_time | 1-2-3-4-5-6-9-10-11 |
1->6 |
late_checkout_time | 1-2-3-4-5-6 |
1->14 |
room_rate | 1-2-3-4-5-6-10-11-14 |
2->11 |
today | 1-2-3-4-5-6-10-11 |
3->7 |
expected_checkout_time | 3-4-5-6-7 |
4->7 |
latest_checkout_time | 4-5-6-7 |
5->12 |
no_of_nights | 5-6-10-11-12 |
du-pair |
Variable |
Path |
1->5 |
checkin_date | 1-2-3-4-5 |
1->8 |
late_checkout_time | 1-2-3-4-5-6-7-8 |
1->14 |
room_rate | 1-2-3-4-5-6-10-11-14 |
2->5 |
today | 2-3-4-5 |
3->8 |
expected_checkout_time | 3-4-5-6-7-8 |
5->12 |
no_of_nights | 5-6-7-9-10-11-12 |
5->14 |
no_of_nights | 5-6-10-11-14 |
du-pair |
Variable |
Path |
1->11 |
checkin_data | 1-2-3-4-5-6-10-11 |
1->11 |
checkout_time | 1-2-3-4-5-6-10-11 |
1->6 |
late_checkout_time | 1-2-3-4-5-6 |
1->7 |
late_checkout_time | 1-2-3-4-5-6-7 |
2->11 |
today | 2-3-4-5-6-10-11 |
3->7 |
exptected_checkout_time | 3-4-5-6-7 |
3->11 |
expected_checkout_time | 3-4-5-6-10-11 |
4->7 |
latest_checkout_time | 4-5-6-7 |
du-pair |
Variable |
Path |
| 1->5 | checkin_date | 1-2-3-4-5 |
| 1->11 | checkin_date | 1-2-3-4-5-6-10-11 |
| 1->11 | checkout_date | 1-2-3-4-5-6-10-11 |
| 1->6 | late_checkout_time | 1-2-3-4-5-6 |
| 1->7 | late_checkout_time | 1-2-3-4-5-6-7 |
| 1->8 | late_checkout_time | 1-2-3-4-5-6-7-8 |
| 1->14 | room_rate | 1-2-3-4-5-6-10-11-14 |
| 2->5 | today | 2-3-4-5 |
| 2->11 | today | 2-3-4-5-6-10-11 |
| 3->7 | expected_checkout_time | 3-4-5-6-7 |
| 3->8 | expected_checkout_time | 3-4-5-6-7-8 |
| 3->11 | expected_checkout_time | 3-4-5-6-10-11 |
| 4->7 | latest_checkout_time | 4-5-6-7 |
| 5->12 | no_of_nights | 5-6-7-9-10-11-12 |
| 5->14 | no_of_nights | 5-6-10-11-14 |
Test Case |
Checkin Date |
Checkout Time |
Late checkout time |
Charge |
du-pair |
1 |
12/8/2006 |
11:30pm |
None |
$425 |
1->5 |
| 1->11 | |||||
| 1->11 | |||||
| 1->6 | |||||
| 1->7 | |||||
| 1->14 | |||||
| 2->5 | |||||
| 2->11 | |||||
| 3->7 | |||||
| 3->11 | |||||
| 4->7 | |||||
| 5->14 | |||||
2 |
12/8/2006 |
2:15pm |
2:30pm |
$425 |
1->8 |
| 3->8 | |||||
3 |
12/8/2006 |
3:15pm |
None |
$510 |
5->12 |