package com.example.springip.lab1.controllers;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

@RestController
public class TestController {
    @GetMapping("/getRandomNumber")
    public String getRandom() {
        Random random = new Random();

        return "Your number = " + random.nextInt(0,100);
    }

//    @GetMapping("/sum")
//    public String getSum(@RequestParam(name = "val1", defaultValue = "1") int val1,
//                            @RequestParam(name="val2",defaultValue = "2") int val2) {
//        return "Your summa = " + (val1 + val2);
//    }

    @GetMapping("/upperCase")
    public String toUpperCase(String word) {
        if (word != null)
            return word.toUpperCase();
        return "Incorrect word";
    }

//    @GetMapping("/length")
//    public String length(String name) {
//        return "Length = " + name.length();
//    }
}
