Skip to content

Commit 5c09c15

Browse files
committed
Digits FRQ
1 parent fe7e702 commit 5c09c15

6 files changed

Lines changed: 105 additions & 14 deletions

File tree

.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: constructor
17+
id: constructor
18+
uses: classroom-resources/autograding-command-grader@v1
19+
with:
20+
test-name: constructor
21+
setup-command: ''
22+
command: gradle test --tests "*constructor*"
23+
timeout: 10
24+
max-score: 1
25+
- name: isStrictlyIncreasing
26+
id: isstrictlyincreasing
27+
uses: classroom-resources/autograding-command-grader@v1
28+
with:
29+
test-name: isStrictlyIncreasing
30+
setup-command: ''
31+
command: gradle test --tests "isStrictlyIncreasing"
32+
timeout: 10
33+
max-score: 1
34+
- name: Autograding Reporter
35+
uses: classroom-resources/autograding-grading-reporter@v1
36+
env:
37+
CONSTRUCTOR_RESULTS: "${{steps.constructor.outputs.result}}"
38+
ISSTRICTLYINCREASING_RESULTS: "${{steps.isstrictlyincreasing.outputs.result}}"
39+
with:
40+
runners: constructor,isstrictlyincreasing

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ When you are done working for now, make sure to commit your changes by going to
66
Give a descriptive message to your changeset, and click the Commit button, make sure to respond "Yes" to staging all changes.<br>
77
After you have committed your changes, you must sync them to your repository.
88

9-
# Tests
10-
```
11-
```
9+
1210
<img width="1280" height="908" alt="Test" src="https://github.com/user-attachments/assets/8fa178c9-f67b-406b-a1fa-fb98fd644e2f" />
1311

1412
<img width="1280" height="864" alt="Commit" src="https://github.com/user-attachments/assets/898ca306-9b43-4ffa-981d-8f29ab081fed" />
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.APCSLowell;
2+
3+
import java.util.ArrayList;
4+
5+
public class Digits {
6+
/** The list of digits from the number used to construct this object.
7+
* The digits appear in the list in the same order in which they appear in the original number
8+
*/
9+
public ArrayList<Integer> digits;
10+
11+
/** Constructs a `Digits` object that represents `num`.
12+
* *Precondition*: `num >= 0`
13+
*/
14+
public Digits(int num) {
15+
/* To be implemented in part (a) */
16+
throw new UnsupportedOperationException();
17+
}
18+
19+
/** Returns `true` if the digits in this `Digits` object are in strictly increasing order;
20+
* `false` otherwise.
21+
*/
22+
public boolean isStrictlyIncreasing() {
23+
/* To be implemented in part (b) */
24+
throw new UnsupportedOperationException();
25+
}
26+
}

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

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.APCSLowell;
2+
3+
import org.junit.Test;
4+
import static org.junit.Assert.*;
5+
6+
public class DigitsTest {
7+
int[] tests = {
8+
57362, 18587, 21600, 15858,
9+
20786, 19398, 1106, 57254,
10+
37318, 3469, 1860, 36752,
11+
9050, 24895, 30845, 13776,
12+
};
13+
14+
@Test
15+
public void constructor() {
16+
Digits digits;
17+
for (int test : tests) {
18+
digits = new Digits(test);
19+
20+
for (int i = 0; i < digits.digits.size(); i++) {
21+
assertEquals(digits.digits.get(i).intValue(), test % 10);
22+
test /= 10;
23+
}
24+
}
25+
}
26+
@Test
27+
public void isStrictlyIncreasing() {
28+
Digits digits;
29+
for (int test : tests) {
30+
digits = new Digits(test);
31+
boolean expected = true;
32+
for (int i = 1; i < digits.digits.size(); i++)
33+
if (digits.digits.get(i) <= digits.digits.get(i-1))
34+
expected = false;
35+
assertEquals(expected, digits.isStrictlyIncreasing());
36+
}
37+
}
38+
}

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

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)