Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 8 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,16 @@
name: Build
on: [push, pull_request]
name: Java CI

permissions:
contents: read
on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v4
uses: actions/setup-java@v2
with:
java-version: 21
distribution: 'temurin'
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
- name: Upload coverage to codecov (tokenless)
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
- name: Upload coverage to codecov (with token)
if: >
github.repository == 'TheAlgorithms/Java' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Checkstyle
run: mvn checkstyle:check
- name: SpotBugs
run: mvn spotbugs:check
- name: PMD
run: mvn pmd:check
java-version: "17"
distribution: "temurin"
- name: Build with javac
run: javac *.java
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ gradle.properties
*.log

/infer-out/
ignore.txt
13 changes: 13 additions & 0 deletions src/main/java/com/thealgorithms/Grade.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.thealgorithms;

public class Grade {
public String getLetterGrade(int score) {
if (score >= 90) {
return "A";
} else if (score >= 80) {
return "B";
} else {
return "C";
}
}
}
24 changes: 24 additions & 0 deletions src/main/java/com/thealgorithms/calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.thealgorithms;

public class calculator {
public int add(int a, int b) {
return a + b; // different change
}


public int subtract(int a, int b) {
return a - b;
}

public int multiply(int a, int b) {
return a * b;
}

public double divide(double a, double b) {
if (b == 0) {
throw new IllegalArgumentException("Division by zero is not allowed");
}
return a / b;
}

}
37 changes: 37 additions & 0 deletions src/main/java/com/thealgorithms/student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.thealgorithms;

public class student {
private String name;
private int age;
private String grade;

public student(String name, int age, String grade) {
this.name = name;
this.age = age;
this.grade = grade;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public String getGrade() {
return grade;
}

public void setGrade(String grade) {
this.grade = grade;
}
}
Loading