Skip to content

Commit 5b52f36

Browse files
committed
Fix grade-school
Example implementation here: exercism/c#683 Fixes #1824
1 parent a423068 commit 5b52f36

File tree

4 files changed

+200
-0
lines changed

4 files changed

+200
-0
lines changed
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
{
2+
"exercise": "grade-school2",
3+
"comments": [
4+
"Given students' names along with the grade that they are in, ",
5+
"create a roster for the school."
6+
],
7+
"cases": [
8+
{
9+
"uuid": "806b873f-13ca-4b19-9161-e3e11bdd15ef",
10+
"description": "Roster is empty when no student is added",
11+
"property": "roster",
12+
"input": {
13+
"students": []
14+
},
15+
"expected": []
16+
},
17+
{
18+
"uuid": "9337267f-7793-4b90-9b4a-8e3978408824",
19+
"description": "Add a student",
20+
"property": "add",
21+
"input": {
22+
"students": [["Aimee", 2]]
23+
},
24+
"expected": true
25+
},
26+
{
27+
"uuid": "aff83e6e-6bdc-4753-9f98-142d19e3f5c4",
28+
"description": "Student is added to the roster",
29+
"property": "roster",
30+
"input": {
31+
"students": [["Aimee", 2]]
32+
},
33+
"expected": ["Aimee"]
34+
},
35+
{
36+
"uuid": "73c3ca75-0c16-40d7-82f5-ed8fe17a8e4a",
37+
"description": "Adding multiple students in same the grade",
38+
"property": "add",
39+
"input": {
40+
"students": [["Blair", 2], ["James", 2], ["Paul", 2]]
41+
},
42+
"expected": [true, true, true]
43+
},
44+
{
45+
"uuid": "c398a433-7a4e-4d80-b379-938944c68a64",
46+
"description": "Multiple students in the same grade are added to the roster",
47+
"property": "roster",
48+
"input": {
49+
"students": [["Blair", 2], ["James", 2], ["Paul", 2]]
50+
},
51+
"expected": ["Blair", "James", "Paul"]
52+
},
53+
{
54+
"uuid": "87c871c1-6bde-4413-9c44-73d59a259d83",
55+
"description": "Cannot add student to same grade more than once",
56+
"property": "add",
57+
"input": {
58+
"students": [["Aimee", 2], ["Aimee", 2]]
59+
},
60+
"expected": [true, false]
61+
},
62+
{
63+
"uuid": "d7982c4f-1602-49f6-a651-620f2614243a",
64+
"description": "Student not added to same grade more than once",
65+
"property": "roster",
66+
"input": {
67+
"students": [["Aimee", 2], ["Aimee", 2]]
68+
},
69+
"expected": ["Aimee"]
70+
},
71+
{
72+
"uuid": "e70d5d8f-43a9-41fd-94a4-1ea0fa338056",
73+
"description": "Adding students in multiple grades",
74+
"property": "add",
75+
"input": {
76+
"students": [["Chelse", 3], ["Logan", 7]]
77+
},
78+
"expected": [true, true]
79+
},
80+
{
81+
"uuid": "d7fe849e-ce01-4612-8b61-05a633c34f26",
82+
"description": "Students in multiple grades are added to the roster",
83+
"property": "roster",
84+
"input": {
85+
"students": [["Chelse", 3], ["Logan", 7]]
86+
},
87+
"expected": ["Chelsea", "Logan"]
88+
},
89+
{
90+
"uuid": "7df542f1-57ce-433c-b249-ff77028ec479",
91+
"description": "Cannot add same student to multiple grades",
92+
"property": "add",
93+
"input": {
94+
"students": [["Aimee", 2], ["Aimee", 1]]
95+
},
96+
"expected": [true, false]
97+
},
98+
{
99+
"uuid": "c7ec1c5e-9ab7-4d3b-be5c-29f2f7a237c5",
100+
"description": "Student not added to multiple grades",
101+
"property": "roster",
102+
"input": {
103+
"students": [["Aimee", 2], ["Aimee", 1]]
104+
},
105+
"expected": ["Aimee"]
106+
},
107+
{
108+
"uuid": "d9af4f19-1ba1-48e7-94d0-dabda4e5aba6",
109+
"description": "Students are sorted by grades in the roster",
110+
"property": "roster",
111+
"input": {
112+
"students": [["Jim", 3], ["Peter", 2], ["Anna", 1]]
113+
},
114+
"expected": ["Anna", "Peter", "Jim"]
115+
},
116+
{
117+
"uuid": "d9fb5bea-f5aa-4524-9d61-c158d8906807",
118+
"description": "Students are sorted by name in the roster",
119+
"property": "roster",
120+
"input": {
121+
"students": [["Peter", 2], ["Zoe", 2], ["Alex", 2]]
122+
},
123+
"expected": ["Alex", "Peter", "Zoe"]
124+
},
125+
{
126+
"uuid": "4227a6ba-7734-4029-83bc-24b1e0bcad82",
127+
"description": "Students are sorted by grades and names in the roster",
128+
"property": "roster",
129+
"input": {
130+
"students": [["Peter", 2], ["Anna", 1], ["Barb", 1], ["Zoe", 2], ["Alex", 2], ["Jim", 3], ["Charlie", 1]]
131+
},
132+
"expected": ["Anna", "Barb", "Charlie", "Alex", "Peter", "Zoe", "Jim"]
133+
},
134+
{
135+
"uuid": "1e0cf06b-26e0-4526-af2d-a2e2df6a51d6",
136+
"description": "Grade is empty if no students in that grade",
137+
"property": "grade",
138+
"input": {
139+
"students": [["Peter", 2], ["Zoe", 2], ["Alex", 2], ["Jim", 3]],
140+
"desiredGrade": 1
141+
},
142+
"expected": []
143+
},
144+
{
145+
"uuid": "779bf69a-f5c4-4b53-949f-3f05fd4bd814",
146+
"description": "Students are sorted by name in a grade",
147+
"property": "roster",
148+
"input": {
149+
"students": [["Franklin", 5], ["Bradley", 5], ["Jeff", 1]],
150+
"desiredGrade": 5
151+
},
152+
"expected": ["Bradley", "Franklin"]
153+
}
154+
]
155+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Description
2+
3+
Given students' names along with the grade that they are in, create a roster
4+
for the school.
5+
6+
In the end, you should be able to:
7+
8+
- Add a student's name to the roster for a grade
9+
- "Add Jim to grade 2."
10+
- "OK."
11+
- Get a list of all students enrolled in a grade
12+
- "Which students are in grade 2?"
13+
- "We've only got Jim just now."
14+
- Get a sorted list of all students in all grades. Grades should sort
15+
as 1, 2, 3, etc., and students within a grade should be sorted
16+
alphabetically by name.
17+
- "Who all is enrolled in school right now?"
18+
- "Let me think. We have
19+
Anna, Barb, and Charlie in grade 1,
20+
Alex, Peter, and Zoe in grade 2
21+
and Jim in grade 5.
22+
So the answer is: Anna, Barb, Charlie, Alex, Peter, Zoe and Jim"
23+
24+
Note that all our students only have one name. (It's a small town, what
25+
do you want?)
26+
27+
## For bonus points
28+
29+
Did you get the tests passing and the code clean? If you want to, these
30+
are some additional things you could try:
31+
32+
- If you're working in a language with mutable data structures and your
33+
implementation allows outside code to mutate the school's internal DB
34+
directly, see if you can prevent this. Feel free to introduce additional
35+
tests.
36+
37+
Then please share your thoughts in a comment on the submission. Did this
38+
experiment make the code better? Worse? Did you learn anything from it?
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
blurb = "Given students' names along with the grade that they are in, create a roster for the school."
2+
source = "A pairing session with Phil Battos at gSchool"
3+
source_url = "http://gschool.it"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
blurb: "Given students' names along with the grade that they are in, create a roster for the school."
3+
source: "A pairing session with Phil Battos at gSchool"
4+
source_url: "http://gschool.it"

0 commit comments

Comments
 (0)