Skip to content

Commit 1cf72f5

Browse files
authored
Add line-up (#345)
* Add `line-up` * Fix errant test file path
1 parent 444d65b commit 1cf72f5

10 files changed

Lines changed: 281 additions & 0 deletions

File tree

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@
120120
"prerequisites": [],
121121
"difficulty": 1
122122
},
123+
{
124+
"slug": "line-up",
125+
"name": "Line Up",
126+
"uuid": "9ede7530-808e-41f4-a1c1-1f528dc9772e",
127+
"practices": [],
128+
"prerequisites": [],
129+
"difficulty": 1
130+
},
123131
{
124132
"slug": "grains",
125133
"name": "Grains",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Instructions
2+
3+
Given a name and a number, your task is to produce a sentence using that name and that number as an [ordinal numeral][ordinal-numeral].
4+
Yaʻqūb expects to use numbers from 1 up to 999.
5+
6+
Rules:
7+
8+
- Numbers ending in 1 (unless ending in 11) → `"st"`
9+
- Numbers ending in 2 (unless ending in 12) → `"nd"`
10+
- Numbers ending in 3 (unless ending in 13) → `"rd"`
11+
- All other numbers → `"th"`
12+
13+
Examples:
14+
15+
- `"Mary", 1``"Mary, you are the 1st customer we serve today. Thank you!"`
16+
- `"John", 12``"John, you are the 12th customer we serve today. Thank you!"`
17+
- `"Dahir", 162``"Dahir, you are the 162nd customer we serve today. Thank you!"`
18+
19+
[ordinal-numeral]: https://en.wikipedia.org/wiki/Ordinal_numeral
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Introduction
2+
3+
Your friend Yaʻqūb works the counter at a deli in town, slicing, weighing, and wrapping orders for a line of hungry customers that gets longer every day.
4+
Waiting customers are starting to lose track of who is next, so he wants numbered tickets they can use to track the order in which they arrive.
5+
6+
To make the customers feel special, he does not want the ticket to have only a number on it.
7+
They shall get a proper English sentence with their name and number on it.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"authors": [
3+
"BNAndras"
4+
],
5+
"files": {
6+
"solution": [
7+
"zcl_line_up.clas.abap"
8+
],
9+
"test": [
10+
"zcl_line_up.clas.testclasses.abap"
11+
],
12+
"example": [
13+
".meta/zcl_line_up.clas.abap"
14+
]
15+
},
16+
"blurb": "Help lining up customers at Yaʻqūb's Deli.",
17+
"source": "mk-mxp, based on previous work from Exercism contributors codedge and neenjaw",
18+
"source_url": "https://forum.exercism.org/t/new-exercise-ordinal-numbers/19147"
19+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[7760d1b8-4864-4db4-953b-0fa7c047dbc0]
13+
description = "format smallest non-exceptional ordinal numeral 4"
14+
15+
[e8b7c715-6baa-4f7b-8fb3-2fa48044ab7a]
16+
description = "format greatest single digit non-exceptional ordinal numeral 9"
17+
18+
[f370aae9-7ae7-4247-90ce-e8ff8c6934df]
19+
description = "format non-exceptional ordinal numeral 5"
20+
21+
[37f10dea-42a2-49de-bb92-0b690b677908]
22+
description = "format non-exceptional ordinal numeral 6"
23+
24+
[d8dfb9a2-3a1f-4fee-9dae-01af3600054e]
25+
description = "format non-exceptional ordinal numeral 7"
26+
27+
[505ec372-1803-42b1-9377-6934890fd055]
28+
description = "format non-exceptional ordinal numeral 8"
29+
30+
[8267072d-be1f-4f70-b34a-76b7557a47b9]
31+
description = "format exceptional ordinal numeral 1"
32+
33+
[4d8753cb-0364-4b29-84b8-4374a4fa2e3f]
34+
description = "format exceptional ordinal numeral 2"
35+
36+
[8d44c223-3a7e-4f48-a0ca-78e67bf98aa7]
37+
description = "format exceptional ordinal numeral 3"
38+
39+
[6c4f6c88-b306-4f40-bc78-97cdd583c21a]
40+
description = "format smallest two digit non-exceptional ordinal numeral 10"
41+
42+
[e257a43f-d2b1-457a-97df-25f0923fc62a]
43+
description = "format non-exceptional ordinal numeral 11"
44+
45+
[bb1db695-4d64-457f-81b8-4f5a2107e3f4]
46+
description = "format non-exceptional ordinal numeral 12"
47+
48+
[60a3187c-9403-4835-97de-4f10ebfd63e2]
49+
description = "format non-exceptional ordinal numeral 13"
50+
51+
[2bdcebc5-c029-4874-b6cc-e9bec80d603a]
52+
description = "format exceptional ordinal numeral 21"
53+
54+
[74ee2317-0295-49d2-baf0-d56bcefa14e3]
55+
description = "format exceptional ordinal numeral 62"
56+
57+
[b37c332d-7f68-40e3-8503-e43cbd67a0c4]
58+
description = "format exceptional ordinal numeral 100"
59+
60+
[0375f250-ce92-4195-9555-00e28ccc4d99]
61+
description = "format exceptional ordinal numeral 101"
62+
63+
[0d8a4974-9a8a-45a4-aca7-a9fb473c9836]
64+
description = "format non-exceptional ordinal numeral 112"
65+
66+
[06b62efe-199e-4ce7-970d-4bf73945713f]
67+
description = "format exceptional ordinal numeral 123"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
CLASS zcl_line_up DEFINITION
2+
PUBLIC
3+
FINAL
4+
CREATE PUBLIC.
5+
6+
PUBLIC SECTION.
7+
METHODS format IMPORTING name TYPE string
8+
number TYPE i
9+
RETURNING VALUE(result) TYPE string.
10+
PROTECTED SECTION.
11+
PRIVATE SECTION.
12+
ENDCLASS.
13+
14+
CLASS zcl_line_up IMPLEMENTATION.
15+
METHOD format.
16+
17+
DATA(suffix) = 'th'.
18+
19+
IF number MOD 100 < 11 OR number MOD 100 > 13.
20+
CASE number MOD 10.
21+
WHEN 1.
22+
suffix = 'st'.
23+
WHEN 2.
24+
suffix = 'nd'.
25+
WHEN 3.
26+
suffix = 'rd'.
27+
ENDCASE.
28+
ENDIF.
29+
30+
result = |{ name }, you are the { number }{ suffix } customer we serve today. Thank you!|.
31+
ENDMETHOD.
32+
ENDCLASS.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_DEVC" serializer_version="v1.0.0">
3+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
4+
<asx:values>
5+
<DEVC>
6+
<CTEXT>Exercism: Line Up</CTEXT>
7+
</DEVC>
8+
</asx:values>
9+
</asx:abap>
10+
</abapGit>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CLASS zcl_line_up DEFINITION
2+
PUBLIC
3+
FINAL
4+
CREATE PUBLIC.
5+
6+
PUBLIC SECTION.
7+
METHODS format IMPORTING name TYPE string
8+
number TYPE i
9+
RETURNING VALUE(result) TYPE string.
10+
PROTECTED SECTION.
11+
PRIVATE SECTION.
12+
ENDCLASS.
13+
14+
CLASS zcl_line_up IMPLEMENTATION.
15+
METHOD format.
16+
"Implement solution
17+
ENDMETHOD.
18+
ENDCLASS.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
CLASS ltcl_line_up DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL.
2+
3+
PRIVATE SECTION.
4+
DATA cut TYPE REF TO zcl_line_up.
5+
METHODS setup.
6+
METHODS:
7+
test_4 FOR TESTING,
8+
test_9 FOR TESTING,
9+
test_1 FOR TESTING,
10+
test_2 FOR TESTING,
11+
test_3 FOR TESTING,
12+
test_11 FOR TESTING,
13+
test_12 FOR TESTING,
14+
test_13 FOR TESTING,
15+
test_21 FOR TESTING,
16+
test_100 FOR TESTING.
17+
ENDCLASS.
18+
19+
CLASS ltcl_line_up IMPLEMENTATION.
20+
METHOD setup.
21+
cut = NEW zcl_line_up( ).
22+
ENDMETHOD.
23+
24+
METHOD test_4.
25+
cl_abap_unit_assert=>assert_equals(
26+
exp = 'Gianna, you are the 4th customer we serve today. Thank you!'
27+
act = cut->format( name = 'Gianna' number = 4 ) ).
28+
ENDMETHOD.
29+
30+
METHOD test_9.
31+
cl_abap_unit_assert=>assert_equals(
32+
exp = 'Maarten, you are the 9th customer we serve today. Thank you!'
33+
act = cut->format( name = 'Maarten' number = 9 ) ).
34+
ENDMETHOD.
35+
36+
METHOD test_1.
37+
cl_abap_unit_assert=>assert_equals(
38+
exp = 'Mary, you are the 1st customer we serve today. Thank you!'
39+
act = cut->format( name = 'Mary' number = 1 ) ).
40+
ENDMETHOD.
41+
42+
METHOD test_2.
43+
cl_abap_unit_assert=>assert_equals(
44+
exp = 'Haruto, you are the 2nd customer we serve today. Thank you!'
45+
act = cut->format( name = 'Haruto' number = 2 ) ).
46+
ENDMETHOD.
47+
48+
METHOD test_3.
49+
cl_abap_unit_assert=>assert_equals(
50+
exp = 'Henriette, you are the 3rd customer we serve today. Thank you!'
51+
act = cut->format( name = 'Henriette' number = 3 ) ).
52+
ENDMETHOD.
53+
54+
METHOD test_11.
55+
cl_abap_unit_assert=>assert_equals(
56+
exp = 'Jacqueline, you are the 11th customer we serve today. Thank you!'
57+
act = cut->format( name = 'Jacqueline' number = 11 ) ).
58+
ENDMETHOD.
59+
60+
METHOD test_12.
61+
cl_abap_unit_assert=>assert_equals(
62+
exp = 'Juan, you are the 12th customer we serve today. Thank you!'
63+
act = cut->format( name = 'Juan' number = 12 ) ).
64+
ENDMETHOD.
65+
66+
METHOD test_13.
67+
cl_abap_unit_assert=>assert_equals(
68+
exp = 'Patricia, you are the 13th customer we serve today. Thank you!'
69+
act = cut->format( name = 'Patricia' number = 13 ) ).
70+
ENDMETHOD.
71+
72+
METHOD test_21.
73+
cl_abap_unit_assert=>assert_equals(
74+
exp = 'Washi, you are the 21st customer we serve today. Thank you!'
75+
act = cut->format( name = 'Washi' number = 21 ) ).
76+
ENDMETHOD.
77+
78+
METHOD test_100.
79+
cl_abap_unit_assert=>assert_equals(
80+
exp = 'John, you are the 100th customer we serve today. Thank you!'
81+
act = cut->format( name = 'John' number = 100 ) ).
82+
ENDMETHOD.
83+
84+
ENDCLASS.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
3+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
4+
<asx:values>
5+
<VSEOCLASS>
6+
<CLSNAME>ZCL_LINE_UP</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>Exercism: Line Up</DESCRIPT>
9+
<STATE>1</STATE>
10+
<CLSCCINCL>X</CLSCCINCL>
11+
<FIXPT>X</FIXPT>
12+
<UNICODE>X</UNICODE>
13+
<WITH_UNIT_TESTS>X</WITH_UNIT_TESTS>
14+
</VSEOCLASS>
15+
</asx:values>
16+
</asx:abap>
17+
</abapGit>

0 commit comments

Comments
 (0)