Sign in

Administrator / allen_calculator · Files

Logo

GitLab

  • Back to dashboard
  • Project
  • Activity
  • Files
  • Commits
  • Network
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Labels
  • Wiki
  • allen_calculator
  • src
  • main
  • java
  • com
  • pengchao
  • Calculator.java
  • feat: add complete calculator project with CI/CD pipeline ...
    0280d821
    - Add Calculator class with basic arithmetic operations
    - Add comprehensive JUnit tests with 100% coverage
    - Configure Maven with SonarQube and JaCoCo plugins for code quality
    - Add Jenkins pipeline for automated build, test and SonarQube analysis
    - Standard Maven project structure ready for CI/CD
    Administrator authored
    2025-10-21 17:41:08 +0800  
    Browse Code »
Calculator.java 439 Bytes
Edit Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
package com.pengchao;

public class Calculator {
    public int add(int a, int b) {
        return a + b;
    }
    
    public int subtract(int a, int b) {
        return a - b;
    }
    
    public int multiply(int a, int b) {
        return a * b;
    }
    
    public double divide(int a, int b) {
        if (b == 0) {
            throw new ArithmeticException("除数不能为零");
        }
        return (double) a / b;
    }
}