final 2 lab
This commit is contained in:
parent
6bd3b5c5be
commit
499575123d
132
front/index.html
132
front/index.html
@ -2,71 +2,109 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>LabWork01</title>
|
||||
<title>LabWork02</title>
|
||||
<script src="/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.min.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-6">
|
||||
<h3 class="text-center font-weight-light my-2">Лабораторная работа 1</h3>
|
||||
<body class="bg-light">
|
||||
<div class="container">
|
||||
<div class="py-5 text-center"><h2>Лабораторная работа 2</h2></div>
|
||||
<div class="row">
|
||||
<div>
|
||||
<form>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="input1">Значение 1 (string или double)</label>
|
||||
<input class="form-control" id="input1" placeholder="Введите значение 1">
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="input1">Значение 2 (string или double)</label>
|
||||
<input class="form-control" id="input2" placeholder="Введите значение 2">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label for="input1">Первая строка</label>
|
||||
<input type="text" class="form-control" id="input1" placeholder="Введите перую строку">
|
||||
<label for="operator">Выберите функцию</label>
|
||||
<select class="form-control" id="operator">
|
||||
<option value>Выбрать...</option>
|
||||
<option value="Func1">(string, double)Сумма</option>
|
||||
<option value="Func2">(double)Минимум, (string)Сумма в верхний регистр</option>
|
||||
<option value="Func3">(double)Mаксимум, (string)Разделить</option>
|
||||
<option value="Func4">(double)Число 1 в степени числа 2, (string)Сумма в нижний регистр</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label for="input2">Вторая строка</label>
|
||||
<input type="text" class="form-control" id="input2" placeholder="Введите вторую строку">
|
||||
<label for="operator">Выберите тип данных</label>
|
||||
<select class="form-control" id="Type">
|
||||
<option value>Выбрать...</option>
|
||||
<option value="str">String</option>
|
||||
<option value="double">Double</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="Sum()">Сумма</button>
|
||||
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="input3">Строка</label>
|
||||
<input type="text" class="form-control" id="input3" placeholder="Введите строку">
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="ToUpper()">В верхний регистр</button>
|
||||
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="input4">Строка</label>
|
||||
<input type="text" class="form-control" id="input4" placeholder="Введите строку">
|
||||
<label for="input5">Разделитель</label>
|
||||
<input type="text" class="form-control" id="input5" placeholder="Введите разделитель">
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="Split()">Разделить</button>
|
||||
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="input6">Строка</label>
|
||||
<input type="text" class="form-control" id="input6" placeholder="Введите строку">
|
||||
<label for="input7">Новый символ</label>
|
||||
<input type="text" class="form-control" id="input7" placeholder="Введите старый символ">
|
||||
<label for="input8">Старый символ</label>
|
||||
<input type="text" class="form-control" id="input8" placeholder="Введите новый символ">
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="Replace()">Заменить</button>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label for="result">Результат</label>
|
||||
<input type="text" class="form-control result" id="result" readonly>
|
||||
<hr class="mb-4">
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="calculate()">Посчитать</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--<div class="container mt-4">-->
|
||||
<!-- <div class="row justify-content-center">-->
|
||||
<!-- <div class="col-lg-6">-->
|
||||
<!-- <h3 class="text-center font-weight-light my-2">Лабораторная работа 2</h3>-->
|
||||
<!-- <form>-->
|
||||
<!-- <div class="form-row">-->
|
||||
<!-- <div class="col">-->
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label for="input1">Значение 1 (string или double)</label>-->
|
||||
<!-- <input class="form-control" id="input1" placeholder="Введите значение 1">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="col">-->
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label for="input2">Значение 2 (string или double)</label>-->
|
||||
<!-- <input class="form-control" id="input2" placeholder="Введите значение 2">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="col">-->
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label for="operator">Выбрать функцию...</label>-->
|
||||
<!-- <select class="form-control" id="operator">-->
|
||||
<!-- <option value="Func1">Сумма</option>-->
|
||||
<!-- <option value="Func2">Минимум, Сумма в верхний регистр</option>-->
|
||||
<!-- <option value="Func3">Mаксимум, Разделить</option>-->
|
||||
<!-- <option value="Func4">Число 1 в степени числа 2, Сумма в нижний регистр</option>-->
|
||||
<!-- </select>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="col">-->
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label for="operator">Выбрать тип данных...</label>-->
|
||||
<!-- <select class="form-control" id="Type">-->
|
||||
<!-- <option value="str">String</option>-->
|
||||
<!-- <option value="double">Double</option>-->
|
||||
<!-- </select>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label for="result">Результат</label>-->
|
||||
<!-- <input type="text" class="form-control result" id="result" readonly>-->
|
||||
<!-- </div>-->
|
||||
<!-- <button type="button" class="btn btn-primary btn-block" onclick="calculate()">Посчитать</button>-->
|
||||
<!-- </form>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!--</div>-->
|
||||
<script src = "script.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,44 +1,13 @@
|
||||
'use strict'
|
||||
let num1 = document.getElementById("input1")
|
||||
let num2 = document.getElementById("input2")
|
||||
let num3 = document.getElementById("input3")
|
||||
let num4 = document.getElementById("input4")
|
||||
let num5 = document.getElementById("input5")
|
||||
let num6 = document.getElementById("input6")
|
||||
let num7 = document.getElementById("input7")
|
||||
let num8 = document.getElementById("input8")
|
||||
|
||||
let operator = document.getElementById("operator")
|
||||
async function calculate(){
|
||||
let num1 = document.getElementById("input1").value
|
||||
let num2 = document.getElementById("input2").value
|
||||
let operator = document.getElementById("operator").value
|
||||
let result = document.getElementById("result")
|
||||
let type = document.getElementById("Type").value
|
||||
|
||||
async function Sum(){
|
||||
let str1 = num1.value
|
||||
let str2 = num2.value
|
||||
let response = await fetch(`http://localhost:8080/Sum/${str1}/${str2}`)
|
||||
let res = await response.text()
|
||||
result.value = res
|
||||
}
|
||||
|
||||
async function ToUpper(){
|
||||
let str3 = num3.value
|
||||
let response = await fetch(`http://localhost:8080/ToUpper/${str3}`)
|
||||
let res = await response.text()
|
||||
result.value = res
|
||||
}
|
||||
|
||||
async function Split(){
|
||||
let str4 = num4.value
|
||||
let str5 = num5.value
|
||||
let response = await fetch(`http://localhost:8080/Split/${str4}/${str5}`)
|
||||
let res = await response.text()
|
||||
result.value = res
|
||||
}
|
||||
|
||||
async function Replace(){
|
||||
let str6 = num6.value
|
||||
let str7 = num7.value
|
||||
let str8 = num8.value
|
||||
let response = await fetch(`http://localhost:8080/Replace/${str6}/${str7}/${str8}`)
|
||||
|
||||
let response = await fetch(`http://localhost:8080/${operator}?Type=${type}&value1=${num1}&value2=${num2}`)
|
||||
let res = await response.text()
|
||||
result.value = res
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.apache.catalina.core.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import ru.ulstu.is.sbapp.interfaces.ITypeOfData;
|
||||
|
||||
@Service
|
||||
|
@ -1,13 +1,88 @@
|
||||
package ru.ulstu.is.sbapp;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import ru.ulstu.is.sbapp.service.ServiceType;
|
||||
|
||||
@SpringBootTest
|
||||
class SbappApplicationTests {
|
||||
|
||||
@Autowired
|
||||
ServiceType Service;
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntPlus() {
|
||||
final String res = (String) Service.Func1( "100", "10", "int");
|
||||
Assertions.assertEquals("110", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntMinus() {
|
||||
final String res = (String)Service.Func2( "100", "10", "int");
|
||||
Assertions.assertEquals("90", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntMultiply() {
|
||||
final String res = (String)Service.Func3( "100", "10", "int");
|
||||
Assertions.assertEquals("1000", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntDivision() {
|
||||
final String res = (String)Service.Func4( "100", "10", "int");
|
||||
Assertions.assertEquals("10", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStringPlus() {
|
||||
final String res = (String)Service.Func1( "abc", "dfe", "str");
|
||||
Assertions.assertEquals("abcdfe", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStringtoUpper() {
|
||||
final String res = (String)Service.Func2( "abc", "dfe", "str");
|
||||
Assertions.assertEquals("ABCDFE", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStringtoLower() {
|
||||
final String res = (String)Service.Func3( "abc", "dfe", "str");
|
||||
Assertions.assertEquals("abcdfe", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStringStrange() {
|
||||
final String res = (String)Service.Func4( "abc", "dfe", "str");
|
||||
Assertions.assertEquals("abcDFE", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDoublePlus() {
|
||||
final String res = (String)Service.Func1( "1.01", "2.76", "double");
|
||||
Assertions.assertEquals("3.7699999999999996", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDoubleMinus() {
|
||||
final String res = (String)Service.Func2( "1.01", "2.76", "double");
|
||||
Assertions.assertEquals("-1.7499999999999998", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDoubleMyltiply() {
|
||||
final String res = (String)Service.Func3( "1.01", "2.76", "double");
|
||||
Assertions.assertEquals("2.7876", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDoubleDivision() {
|
||||
final String res = (String)Service.Func4( "1.01", "2.76", "double");
|
||||
Assertions.assertEquals("0.36594202898550726", res);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user