diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c21d1a09eb5..df4965800303 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/src/main/java/com/thealgorithms/Grade.java b/src/main/java/com/thealgorithms/Grade.java new file mode 100644 index 000000000000..4bf972aea5de --- /dev/null +++ b/src/main/java/com/thealgorithms/Grade.java @@ -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"; + } + } +} diff --git a/src/main/java/com/thealgorithms/calculator.java b/src/main/java/com/thealgorithms/calculator.java new file mode 100644 index 000000000000..d7f3b257939c --- /dev/null +++ b/src/main/java/com/thealgorithms/calculator.java @@ -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; + } + +} diff --git a/src/main/java/com/thealgorithms/student.java b/src/main/java/com/thealgorithms/student.java new file mode 100644 index 000000000000..410c4e19190f --- /dev/null +++ b/src/main/java/com/thealgorithms/student.java @@ -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; + } +}