Skip to content

Commit d76a287

Browse files
committed
APLine
1 parent fe7e702 commit d76a287

File tree

5 files changed

+62
-11
lines changed

5 files changed

+62
-11
lines changed

.github/workflows/classroom.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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: test
17+
id: test
18+
uses: classroom-resources/autograding-command-grader@v1
19+
with:
20+
test-name: test
21+
setup-command: ''
22+
command: gradle test --tests "APLineTest.test"
23+
timeout: 10
24+
max-score: 1
25+
- name: Autograding Reporter
26+
uses: classroom-resources/autograding-grading-reporter@v1
27+
env:
28+
TEST_RESULTS: "${{steps.test.outputs.result}}"
29+
with:
30+
runners: test
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.APCSLowell;
2+
3+
public class APLine {
4+
int a, b, c;
5+
public APLine(int a, int b, int c) {}
6+
public boolean isOnLine(int x, int y) {
7+
return a * x + b * y + c == 0;
8+
}
9+
public double getSlope() {
10+
return -(double)a / (double)b;
11+
}
12+
}

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

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.APCSLowell;
2+
3+
import org.junit.Test;
4+
import static org.junit.Assert.*;
5+
6+
public class APLineTest {
7+
@Test
8+
public void test() {
9+
APLine line1 = new APLine(5,4,-17);
10+
double slope1 = line1.getSlope();
11+
assertEquals(slope1,-1.25,0.01);
12+
boolean onLine1 = line1.isOnLine(5,-2);
13+
assertEquals(onLine1,true);
14+
APLine line2 = new APLine(-25,40,30);
15+
double slope2 = line2.getSlope();
16+
assertEquals(slope2,0.625,0.01);
17+
boolean onLine2 = line2.isOnLine(5,-2);
18+
assertEquals(onLine2,false);
19+
}
20+
}

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

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

0 commit comments

Comments
 (0)