Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding/<project>=UTF-8
5 changes: 5 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
34 changes: 34 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Johan</groupId>
<artifactId>app</artifactId>
<packaging>jar</packaging>
<version>1</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>1.5.2.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
24 changes: 24 additions & 0 deletions src/main/java/Johan/rakendus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package Johan;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*;

@SpringBootApplication
@RestController
public class rakendus{

@RequestMapping("/silinder")
public String ruumala(double korgus, double raadius) {
silinder s1 = new silinder(korgus, raadius);
return "Silindri ruumala on " + s1.silindriRuumala();
}

public static void main(String[] arg) {
System.getProperties().put("server.port", 4220);
SpringApplication.run(rakendus.class, arg);
}
}
//scl enable rh-maven33 bash
//mvn package
//java -jar target/boot3-1.0-SNAPSHOT.jar
12 changes: 12 additions & 0 deletions src/main/java/Johan/ruumala.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package Johan;

public abstract class ruumala {
double h;
public ruumala(double korgus) {
h=korgus;
}
public abstract double Ringipindala();
public double silindriRuumala() {
return 3.14*h*Ringipindala();
}
}
14 changes: 14 additions & 0 deletions src/main/java/Johan/silinder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package Johan;

public class silinder extends ruumala {
double r;
public silinder(double raadius, double korgus) {
super(korgus);
r=raadius;
}

@Override
public double Ringipindala(){
return Math.pow(r, 2) ;
}
}
33 changes: 33 additions & 0 deletions src/main/resources/public/arvutus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE HTML>
<html>
<head>
<script>
var yhendus=new XMLHttpRequest();
yhendus.onreadystatechange=andmedSaabusid;
function vajutus(){
var height=document.getElementById("height").value;
var radius=document.getElementById("radius").value;
yhendus.open("GET","/silinder?raadius="+radius+"&korgus="+height, true);
yhendus.send();
}


function andmedSaabusid(){
document.getElementById("vastus").innerHTML=yhendus.responseText;
}

</script>
</head>
<body>
<h1>Silindri ruumala arvutamine</h1>
<br><br>
Sisesta silindri kõrgus<br>
<input type="text" id="height" placeholder="h"/><br>
Sisesta silindri põhja raadius<br>
<input type="text" id="radius" placeholder="r"/>
<br>
<input type="button" value="Arvuta" onclick="vajutus()"/>
<br><br>
<div id="vastus">Vastus: </div>
</body>
</html>
27 changes: 27 additions & 0 deletions src/test/Johan/rakendusTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package Johan;

import org.junit.*;
import static org.junit.Assert.*;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;


@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)

public class rakendusTest{
@Autowired
private TestRestTemplate restTemplate;

@Test
public void pindala1(){
String vastus = this.restTemplate.getForObject("/pindala?raadius=5&korgus=4",String.class);

assertEquals("Silindri ruumala on ",vastus.substring(0, 20));
assertEquals(314.16, Double.parseDouble(vastus.substring(20)),0.2);
}
}
Binary file added target/classes/Johan/rakendus.class
Binary file not shown.
Binary file added target/classes/Johan/ruumala.class
Binary file not shown.
Binary file added target/classes/Johan/silinder.class
Binary file not shown.
33 changes: 33 additions & 0 deletions target/classes/public/arvutus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE HTML>
<html>
<head>
<script>
var yhendus=new XMLHttpRequest();
yhendus.onreadystatechange=andmedSaabusid;
function vajutus(){
var height=document.getElementById("height").value;
var radius=document.getElementById("radius").value;
yhendus.open("GET","/silinder?raadius="+radius+"&korgus="+height, true);
yhendus.send();
}


function andmedSaabusid(){
document.getElementById("vastus").innerHTML=yhendus.responseText;
}

</script>
</head>
<body>
<h1>Silindri ruumala arvutamine</h1>
<br><br>
Sisesta silindri kõrgus<br>
<input type="text" id="height" placeholder="h"/><br>
Sisesta silindri põhja raadius<br>
<input type="text" id="radius" placeholder="r"/>
<br>
<input type="button" value="Arvuta" onclick="vajutus()"/>
<br><br>
<div id="vastus">Vastus: </div>
</body>
</html>