From 059729f98696c530581223afec754b0581a6a7d2 Mon Sep 17 00:00:00 2001 From: maxnes3 <112558334+maxnes3@users.noreply.github.com> Date: Thu, 11 May 2023 21:56:05 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=B3=D0=BE=D0=B2?= =?UTF-8?q?=D0=BD=D0=BE=D0=B5=D0=B4=20=D0=B8=20=D0=9A=D0=BE=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=82=D0=BE=D0=B6=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- data.mv.db | Bin 839680 -> 217088 bytes data.trace.db | 116 ++++++++++++++++++ .../bookshop/controller/BookController.java | 2 +- .../calculator/controller/UserController.java | 35 ------ .../calculator/domain/ArrayCalculator.java | 48 -------- .../calculator/domain/ITypeCalculator.java | 9 -- .../calculator/domain/IntCalculator.java | 26 ---- .../calculator/domain/StringCalculator.java | 31 ----- .../calculator/service/CalculatorService.java | 66 ---------- 10 files changed, 118 insertions(+), 217 deletions(-) delete mode 100644 src/main/java/ru/ip/labworks/labworks/calculator/controller/UserController.java delete mode 100644 src/main/java/ru/ip/labworks/labworks/calculator/domain/ArrayCalculator.java delete mode 100644 src/main/java/ru/ip/labworks/labworks/calculator/domain/ITypeCalculator.java delete mode 100644 src/main/java/ru/ip/labworks/labworks/calculator/domain/IntCalculator.java delete mode 100644 src/main/java/ru/ip/labworks/labworks/calculator/domain/StringCalculator.java delete mode 100644 src/main/java/ru/ip/labworks/labworks/calculator/service/CalculatorService.java diff --git a/build.gradle b/build.gradle index eb5d960..87c4075 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' developmentOnly 'org.springframework.boot:spring-boot-devtools' implementation 'com.h2database:h2:2.1.210' - implementation 'org.hibernate.validator:hibernate-validator:7.0.1.Final' + implementation 'org.hibernate.validator:hibernate-validator:6.0.17.Final' implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' testImplementation 'org.springframework.boot:spring-boot-starter-test' diff --git a/data.mv.db b/data.mv.db index a359dc6f8f8ecb717be57cb18dd50758eed4c3b4..8fa6adaf703c24366434d5becefd83daf7b0e276 100644 GIT binary patch delta 5403 zcmd^DTWlRi8J<}m`>gG8u5L)1+ew=yG@K?gJ9|AyU{F;;Pzt3D7$oHE&h9o=o#VSx zc;FmB3RI#>?MfLzRS1cqa+7k79de4Q3Y(XzFWi*}q_jNoLJ5xu30h|FdyXB~p?!$N z%JS^Y?wMf2y&hX(z! zKjzJ_)816YwmsFt%LW3CQ7Ok7#Cc;wC2^U%3Jg^QXR3 zxQCB?7s|Ds0KyUfB8=C^jPVn%98SO}kB!cGCj@+AG6RRb&xPoxUHl3f}i5H2!z7StV2a)CC^YyJumKPrlDgc>-fQKG0TG= z0HA9bfN~vx2Y@)pf@z3b0D$qR6buGe#9=J(zb>L%ytIT4@X~eoIDcsg4)aNI)+%2^ z!%{RDTy72h0zCrxi!DSsy^bE|ziA=dUAVSs4)T4kpa%!L#cCg+J>h>dYOL14kKit8 z$30bB1m5_BSABBIu1?!*M#SAT|L|qFSJD_i7PYOfUxx3%5o$`*65;m8ftwOQtHaGn z!i^Qrcr*5qQ8!VaR2_1WoobO!Rhy|U3u64S7wV-#tq(^ercsckBvv~ZqKBJ9bw6W> z<6_5lVulDsaXed5*5I_AF~*KKjZG(}%+4V4uyHjZwUb01-?swy*JvOCBK8Go)`~50 zArv-h5iL`IJd8l-1cf|vHIbbRmJ`7ujOCeZz*<1%FftUOF?!NzBX3(LW^%-F#rM^X zl2_2MF8KO=(GCIW+z!zS3QJ4dnv-t~ER>1|+3I~|S&s3sVlm=c>Av!JYfyGNbu1?Z zx09>&)GB3ECQZQ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|!VGC^^he{CXrEzHC94DgoQKgU!;4(6(D1sGLR8>(uKncGYLBw9qobrGqJrDXN z>u@gPcQ}^V;rJ2(^6JizRy zj@em4`mjsuXGzb6%U(IXz0rf%!?>&419>$AxqxQ?@;waXu8`RPzWl6ZE3$JZr>(Bo<5DBMf`dJvX{OfS#7&%@u~^J5lsoR?|M1S09}K+Hq3V*<8R zMf-QEM5iX8g-dD?n4?O#qoLrAMo>`{E2`jroaR5l%_d7_TNP-dgx`uZVn1&>?bG?_ z7QbX&$|0q!OR=2Z-p=e4$R9EU4#&ToOjAz|X)m}c4RgOZk(mWqD?`>e(r diff --git a/data.trace.db b/data.trace.db index 7f01ec3..dc565db 100644 --- a/data.trace.db +++ b/data.trace.db @@ -1288,3 +1288,119 @@ GROUP BY a.id [90079-210] at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:1589) +2023-05-11 21:51:50 database: wrong user or password; user: "SA" +org.h2.message.DbException: Неверное имя пользователя или пароль +Wrong user name or password [28000-210] + at org.h2.message.DbException.get(DbException.java:227) + at org.h2.message.DbException.get(DbException.java:203) + at org.h2.message.DbException.get(DbException.java:192) + at org.h2.engine.Engine.openSession(Engine.java:154) + at org.h2.engine.Engine.openSession(Engine.java:222) + at org.h2.engine.Engine.createSession(Engine.java:201) + at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338) + at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:122) + at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288) + at org.h2.server.web.WebServer.getConnection(WebServer.java:807) + at org.h2.server.web.WebApp.login(WebApp.java:1033) + at org.h2.server.web.WebApp.process(WebApp.java:226) + at org.h2.server.web.WebApp.processRequest(WebApp.java:176) + at org.h2.server.web.WebServlet.doGet(WebServlet.java:129) + at org.h2.server.web.WebServlet.doPost(WebServlet.java:166) + at javax.servlet.http.HttpServlet.service(HttpServlet.java:696) + at javax.servlet.http.HttpServlet.service(HttpServlet.java:779) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) + at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) + at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) + at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) + at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) + at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177) + at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) + at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) + at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) + at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) + at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) + at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) + at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) + at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) + at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891) + at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784) + at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) + at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) + at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) + at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) + at java.base/java.lang.Thread.run(Thread.java:1589) +Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль +Wrong user name or password [28000-210] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:529) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:496) + ... 50 more +2023-05-11 21:51:59 database: wrong user or password; user: "SA" +org.h2.message.DbException: Неверное имя пользователя или пароль +Wrong user name or password [28000-210] + at org.h2.message.DbException.get(DbException.java:227) + at org.h2.message.DbException.get(DbException.java:203) + at org.h2.message.DbException.get(DbException.java:192) + at org.h2.engine.Engine.openSession(Engine.java:154) + at org.h2.engine.Engine.openSession(Engine.java:222) + at org.h2.engine.Engine.createSession(Engine.java:201) + at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338) + at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:122) + at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288) + at org.h2.server.web.WebServer.getConnection(WebServer.java:807) + at org.h2.server.web.WebApp.login(WebApp.java:1033) + at org.h2.server.web.WebApp.process(WebApp.java:226) + at org.h2.server.web.WebApp.processRequest(WebApp.java:176) + at org.h2.server.web.WebServlet.doGet(WebServlet.java:129) + at org.h2.server.web.WebServlet.doPost(WebServlet.java:166) + at javax.servlet.http.HttpServlet.service(HttpServlet.java:696) + at javax.servlet.http.HttpServlet.service(HttpServlet.java:779) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) + at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) + at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) + at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) + at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) + at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177) + at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) + at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) + at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) + at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) + at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) + at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) + at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) + at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) + at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891) + at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784) + at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) + at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) + at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) + at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) + at java.base/java.lang.Thread.run(Thread.java:1589) +Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль +Wrong user name or password [28000-210] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:529) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:496) + ... 50 more diff --git a/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookController.java b/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookController.java index c57f11f..087c20f 100644 --- a/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookController.java +++ b/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookController.java @@ -8,7 +8,7 @@ import java.io.IOException; import java.util.List; @RestController -@RequestMapping("/post") +@RequestMapping("/book") public class BookController { private final BookService bookService; diff --git a/src/main/java/ru/ip/labworks/labworks/calculator/controller/UserController.java b/src/main/java/ru/ip/labworks/labworks/calculator/controller/UserController.java deleted file mode 100644 index 1f67409..0000000 --- a/src/main/java/ru/ip/labworks/labworks/calculator/controller/UserController.java +++ /dev/null @@ -1,35 +0,0 @@ -package ru.ip.labworks.labworks.calculator.controller; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import ru.ip.labworks.labworks.calculator.service.CalculatorService; - -@RestController -public class UserController { - private CalculatorService calculatorService; - - public UserController(CalculatorService calculatorService){ - this.calculatorService = calculatorService; - } - - @GetMapping("/+") - public String workPlus(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){ - return (String) calculatorService.Plus(type, arg1, arg2); - } - - @GetMapping("/-") - public String workMinus(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){ - return (String) calculatorService.Minus(type, arg1, arg2); - } - - @GetMapping("/*") - public String workMulti(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){ - return (String) calculatorService.Multi(type, arg1, arg2); - } - - @GetMapping("/:") - public String workDiv(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){ - return (String) calculatorService.Div(type, arg1, arg2); - } -} diff --git a/src/main/java/ru/ip/labworks/labworks/calculator/domain/ArrayCalculator.java b/src/main/java/ru/ip/labworks/labworks/calculator/domain/ArrayCalculator.java deleted file mode 100644 index ffb228d..0000000 --- a/src/main/java/ru/ip/labworks/labworks/calculator/domain/ArrayCalculator.java +++ /dev/null @@ -1,48 +0,0 @@ -package ru.ip.labworks.labworks.calculator.domain; - -import org.springframework.stereotype.Component; - -import java.util.ArrayList; - -@Component(value = "array") -public class ArrayCalculator implements ITypeCalculator> { - @Override - public ArrayList Plus(ArrayList arg1, ArrayList arg2) { - ArrayList result = new ArrayList<>(); - for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){ - result.add(arg1.get(i) + arg2.get(i)); - } - return result; - } - - @Override - public ArrayList Minus(ArrayList arg1, ArrayList arg2) { - ArrayList result = new ArrayList<>(); - for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){ - result.add(arg1.get(i).replace(arg2.get(i), "")); - } - return result; - } - - @Override - public ArrayList Multi(ArrayList arg1, ArrayList arg2) { - ArrayList result = new ArrayList<>(); - for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){ - String temp = ""; - for (int j = 0; j < Integer.parseInt(arg2.get(i)); ++j){ - temp += arg1.get(i); - } - result.add(temp); - } - return result; - } - - @Override - public ArrayList Div(ArrayList arg1, ArrayList arg2) { - ArrayList result = new ArrayList<>(); - for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){ - result.add(arg1.get(i).substring(0, Integer.parseInt(arg2.get(i)))); - } - return result; - } -} diff --git a/src/main/java/ru/ip/labworks/labworks/calculator/domain/ITypeCalculator.java b/src/main/java/ru/ip/labworks/labworks/calculator/domain/ITypeCalculator.java deleted file mode 100644 index 366a46c..0000000 --- a/src/main/java/ru/ip/labworks/labworks/calculator/domain/ITypeCalculator.java +++ /dev/null @@ -1,9 +0,0 @@ -package ru.ip.labworks.labworks.calculator.domain; - -public interface ITypeCalculator { - - T Plus(T arg1, T arg2); - T Minus(T arg1, T arg2); - T Multi(T arg1, T arg2); - T Div(T arg1, T arg2); -} diff --git a/src/main/java/ru/ip/labworks/labworks/calculator/domain/IntCalculator.java b/src/main/java/ru/ip/labworks/labworks/calculator/domain/IntCalculator.java deleted file mode 100644 index 947e6fc..0000000 --- a/src/main/java/ru/ip/labworks/labworks/calculator/domain/IntCalculator.java +++ /dev/null @@ -1,26 +0,0 @@ -package ru.ip.labworks.labworks.calculator.domain; - -import org.springframework.stereotype.Component; - -@Component(value = "int") -public class IntCalculator implements ITypeCalculator{ - @Override - public Integer Plus(Integer arg1, Integer arg2) { - return arg1 + arg2; - } - - @Override - public Integer Minus(Integer arg1, Integer arg2) { - return arg1 - arg2; - } - - @Override - public Integer Multi(Integer arg1, Integer arg2) { - return arg1 * arg2; - } - - @Override - public Integer Div(Integer arg1, Integer arg2) { - return arg1 / arg2; - } -} diff --git a/src/main/java/ru/ip/labworks/labworks/calculator/domain/StringCalculator.java b/src/main/java/ru/ip/labworks/labworks/calculator/domain/StringCalculator.java deleted file mode 100644 index 4b8d417..0000000 --- a/src/main/java/ru/ip/labworks/labworks/calculator/domain/StringCalculator.java +++ /dev/null @@ -1,31 +0,0 @@ -package ru.ip.labworks.labworks.calculator.domain; - -import org.springframework.stereotype.Component; - -@Component(value = "string") -public class StringCalculator implements ITypeCalculator{ - @Override - public String Plus(String arg1, String arg2) { - return arg1 + arg2; - } - - @Override - public String Minus(String arg1, String arg2) { - return arg1.replaceAll(arg2, ""); - } - - @Override - public String Multi(String arg1, String arg2) { - String result = ""; - for (int i = 0; i < Integer.parseInt(arg2); ++i){ - result += arg1; - } - return result; - } - - @Override - public String Div(String arg1, String arg2) { - String result = arg1.substring(0, arg1.length() / Integer.parseInt(arg2)); - return result; - } -} diff --git a/src/main/java/ru/ip/labworks/labworks/calculator/service/CalculatorService.java b/src/main/java/ru/ip/labworks/labworks/calculator/service/CalculatorService.java deleted file mode 100644 index c653218..0000000 --- a/src/main/java/ru/ip/labworks/labworks/calculator/service/CalculatorService.java +++ /dev/null @@ -1,66 +0,0 @@ -package ru.ip.labworks.labworks.calculator.service; - -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Service; -import ru.ip.labworks.labworks.calculator.domain.ITypeCalculator; - -import java.util.ArrayList; -import java.util.Arrays; - -@Service -public class CalculatorService { - private final ApplicationContext applicationContext; - private ITypeCalculator typeCalculator; - private Object arg1; - private Object arg2; - - public CalculatorService(ApplicationContext applicationContext){ - this.applicationContext = applicationContext; - } - - private boolean ValidateParams(Object value1, Object value2, String type){ - typeCalculator = (ITypeCalculator)applicationContext.getBean(type); - - try { - switch (type) { - case "int" -> { - arg1 = Integer.valueOf(value1.toString()); - arg2 = Integer.valueOf(value2.toString()); - } - case "array" -> { - arg1 = new ArrayList<>(Arrays.asList(value1.toString().split(","))); - arg2 = new ArrayList<>(Arrays.asList(value2.toString().split(","))); - } - case "string" -> { - arg1 = value1.toString(); - arg2 = value2.toString(); - } - } - } - catch (Exception ex){ - return false; - } - return true; - } - - - public Object Plus(String type, Object arg1, Object arg2){ - if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные"); - return String.format("%s", typeCalculator.Plus(this.arg1, this.arg2)); - } - - public Object Minus(String type, Object arg1, Object arg2){ - if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные"); - return String.format("%s", typeCalculator.Minus(this.arg1, this.arg2)); - } - - public Object Multi(String type, Object arg1, Object arg2){ - if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные"); - return String.format("%s", typeCalculator.Multi(this.arg1, this.arg2)); - } - - public Object Div(String type, Object arg1, Object arg2){ - if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные"); - return String.format("%s", typeCalculator.Div(this.arg1, this.arg2)); - } -}