Skip to content

Commit 3517f74

Browse files
committed
18-07-2025
1 parent 178925e commit 3517f74

4 files changed

Lines changed: 73 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Java CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Set up JDK 17
13+
uses: actions/setup-java@v3
14+
with:
15+
java-version: '17'
16+
distribution: 'adopt'
17+
18+
- name: Compile Java code
19+
run: javac -d out src/*.java test/*.java
20+
21+
- name: Run tests
22+
run: |
23+
wget https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/1.9.3/junit-platform-console-standalone-1.9.3.jar
24+
java -jar junit-platform-console-standalone-1.9.3.jar --classpath out --scan-classpath

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Java Assignment: Classes and Objects
2+
3+
## Tasks
4+
1. Create a class called `Student` with:
5+
- `String name`
6+
- `int rollNumber`
7+
- `char grade`
8+
9+
2. Create a method `displayDetails()` in the `Student` class that prints student information.
10+
11+
3. In `Main.java`, create a `Student` object, assign sample data, and call `displayDetails()`.
12+
13+
## Submission Instructions
14+
- Complete the TODOs in `Main.java`
15+
- Push your code. Your submission will be tested automatically.

src/Main.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public class Main {
2+
3+
// TODO: Create a class called Student with name, rollNumber, and grade
4+
5+
// TODO: Create a method to display student details
6+
7+
public static void main(String[] args) {
8+
// TODO: Create a Student object and call the method to display details
9+
}
10+
}

test/MainTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import static org.junit.Assert.*;
2+
import org.junit.Test;
3+
4+
public class MainTest {
5+
6+
@Test
7+
public void testStudentClassExists() {
8+
try {
9+
Class.forName("Student");
10+
} catch (ClassNotFoundException e) {
11+
fail("Class 'Student' not found. Please define it.");
12+
}
13+
}
14+
15+
@Test
16+
public void testDisplayMethodExists() {
17+
try {
18+
Class<?> clazz = Class.forName("Student");
19+
clazz.getMethod("displayDetails");
20+
} catch (Exception e) {
21+
fail("Method 'displayDetails' not found in class 'Student'.");
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)