Skip to content

Commit 8d274e8

Browse files
committed
RandomStringChooser
1 parent fe7e702 commit 8d274e8

File tree

8 files changed

+93
-12
lines changed

8 files changed

+93
-12
lines changed

.github/workflows/classroom.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Autograding Tests
2+
'on':
3+
- push
4+
- repository_dispatch
5+
permissions:
6+
checks: write
7+
actions: read
8+
contents: read
9+
jobs:
10+
run-autograding-tests:
11+
runs-on: ubuntu-latest
12+
if: github.actor != 'github-classroom[bot]'
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
- name: parta1
17+
id: parta1
18+
uses: classroom-resources/autograding-command-grader@v1
19+
with:
20+
test-name: parta1
21+
setup-command: ''
22+
command: gradle test --tests "SoundTest.partA1"
23+
timeout: 10
24+
max-score: 1
25+
- name: parta
26+
id: parta
27+
uses: classroom-resources/autograding-command-grader@v1
28+
with:
29+
test-name: parta
30+
setup-command: ''
31+
command: gradle test --tests "SoundTest.partB"
32+
timeout: 10
33+
max-score: 1
34+
- name: Autograding Reporter
35+
uses: classroom-resources/autograding-grading-reporter@v1
36+
env:
37+
PARTA_RESULTS: "${{steps.parta.outputs.result}}"
38+
PARTB_RESULTS: "${{steps.partb.outputs.result}}"
39+
with:
40+
runners: parta1,parta2,parta3,parta4,partb1,partb2

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# GitHub Classroom Java Template
1+
# Random String Chooser
2+
FRQ: https://secure-media.collegeboard.org/digitalServices/pdf/ap/ap16_frq_computer_science_a.pdf
3+
24
To edit your code, click on the "Code" button, select Codespaces, and create a new Codespace, or open an existing one.<br>
35
When your codespace is open you will see a loading circle on the bottom bar. Wait until this goes away.<br>
46
To run tests, go to the Gradle (elephant) tab in the sidebar, and run the "build" step, under lib/tasks/build/.<br>

lib/src/main/java/org/APCSLowell/Library.java

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.APCSLowell;
2+
3+
// FRQ: https://secure-media.collegeboard.org/digitalServices/pdf/ap/ap16_frq_computer_science_a.pdf
4+
public class RandomLetterChooser extends RandomStringChooser {}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.APCSLowell;
2+
3+
// FRQ: https://secure-media.collegeboard.org/digitalServices/pdf/ap/ap16_frq_computer_science_a.pdf
4+
public class RandomStringChooser {}

lib/src/test/java/org/APCSLowell/LibraryTest.java

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.APCSLowell;
2+
3+
import org.junit.Test;
4+
import static org.junit.Assert.*;
5+
6+
public class RandomLetterChooserTest {
7+
@Test
8+
public void randomLetterChooserTest(){
9+
RandomLetterChooser letterChooser = new RandomLetterChooser("cat");
10+
String test = "";
11+
for(int i = 0; i < 4; i++)
12+
test+=letterChooser.getNext();
13+
assertEquals(7,test.length());
14+
assertEquals("NONE",test.substring(3));
15+
assertEquals(true,test.contains("c"));
16+
assertEquals(true,test.contains("a"));
17+
assertEquals(true,test.contains("t"));
18+
}
19+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.APCSLowell;
2+
3+
import org.junit.Test;
4+
import static org.junit.Assert.*;
5+
6+
public class RandomStringChooserTest {
7+
@Test
8+
public void randomStringChooserTest() {
9+
List<String> test = new ArrayList<>();
10+
String[] wordArray = { "wheels", "on", "the", "bus" };
11+
RandomStringChooser sChooser = new RandomStringChooser(wordArray);
12+
for (int k = 0; k < 6; k++) {
13+
test.add(sChooser.getNext());
14+
}
15+
assertEquals(6, test.size());
16+
assertEquals("NONE", test.get(4));
17+
assertEquals("NONE", test.get(5));
18+
assertEquals(true, test.contains("wheels"));
19+
assertEquals(true, test.contains("on"));
20+
assertEquals(true, test.contains("the"));
21+
assertEquals(true, test.contains("bus"));
22+
}
23+
}

0 commit comments

Comments
 (0)