This commit is contained in:
Марат Заргаров 2023-10-07 17:53:20 +04:00
parent 8f92046359
commit c2e7630c66
5 changed files with 4 additions and 26 deletions

View File

@ -5,7 +5,9 @@ import com.labs.LabWork.Calculator.Domain.StringCalculator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class CalculatorConfiguration {
private final Logger log = LoggerFactory.getLogger(CalculatorConfiguration.class);

View File

@ -2,7 +2,6 @@ package com.labs.LabWork.Calculator.Domain;
import org.springframework.stereotype.Component;
@Component(value = "int")
public class IntCalculator implements ICalculator<Integer>{
@Override
public Integer sum(Integer num1, Integer num2) {

View File

@ -2,7 +2,6 @@ package com.labs.LabWork.Calculator.Domain;
import org.springframework.stereotype.Component;
@Component(value = "string")
public class StringCalculator implements ICalculator<String> {
@Override
public String sum(String s1, String s2) {

View File

@ -8,31 +8,9 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Random;
@SpringBootApplication
@RestController
public class LabWorkApplication {
public static void main(String[] args) {
SpringApplication.run(LabWorkApplication.class, args);
}
@GetMapping("/doExp")
public double doExp(@RequestParam int val){
return Math.pow(val,2);
}
@GetMapping("/doSin")
public double doSin(@RequestParam int val) {
return Math.sin(val);
}
@GetMapping("/doAbs")
public int doAbs(@RequestParam int val) {
return Math.abs(val);
}
Random random = new Random();
@GetMapping("/doRand")
public int doRand(@RequestParam int val){
return random.nextInt(val);
}
}

View File

@ -61,8 +61,8 @@ class LabWorkApplicationTests {
@Test
void testStringDiv(){
final Object res = calculatorService.division("124", "24", "string");
Assertions.assertEquals("1", res.toString());
final Object res = calculatorService.division("2", "2", "string");
Assertions.assertEquals("22", res.toString());
}
@Test