From 2b6046546647993c6edd718a21837fe33ada852c Mon Sep 17 00:00:00 2001 From: ciruss Date: Tue, 30 May 2017 03:02:15 +0300 Subject: [PATCH 1/2] homework --- .classpath | 26 ++++++++++++++++ .project | 23 ++++++++++++++ .settings/org.eclipse.core.resources.prefs | 3 ++ .settings/org.eclipse.jdt.core.prefs | 5 +++ .settings/org.eclipse.m2e.core.prefs | 4 +++ pom.xml | 34 +++++++++++++++++++++ src/main/java/Johan/rakendus.java | 24 +++++++++++++++ src/main/java/Johan/ruumala.java | 12 ++++++++ src/main/java/Johan/silinder.java | 14 +++++++++ src/main/resources/public/arvutus.html | 33 ++++++++++++++++++++ src/test/Johan/pindalaTest.java | 27 ++++++++++++++++ target/classes/Johan/rakendus.class | Bin 0 -> 1561 bytes target/classes/Johan/ruumala.class | Bin 0 -> 459 bytes target/classes/Johan/silinder.class | Bin 0 -> 487 bytes target/classes/public/arvutus.html | 33 ++++++++++++++++++++ 15 files changed, 238 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 pom.xml create mode 100644 src/main/java/Johan/rakendus.java create mode 100644 src/main/java/Johan/ruumala.java create mode 100644 src/main/java/Johan/silinder.java create mode 100644 src/main/resources/public/arvutus.html create mode 100644 src/test/Johan/pindalaTest.java create mode 100644 target/classes/Johan/rakendus.class create mode 100644 target/classes/Johan/ruumala.class create mode 100644 target/classes/Johan/silinder.class create mode 100644 target/classes/public/arvutus.html diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..fd7ad7f --- /dev/null +++ b/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..14affec --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + app + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..e9441bb --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..60105c1 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..cbd19b6 --- /dev/null +++ b/pom.xml @@ -0,0 +1,34 @@ + + 4.0.0 + Johan + app + jar + 1 + + + org.springframework.boot + spring-boot-starter-parent + 1.5.2.RELEASE + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + 1.5.2.RELEASE + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/src/main/java/Johan/rakendus.java b/src/main/java/Johan/rakendus.java new file mode 100644 index 0000000..92c8975 --- /dev/null +++ b/src/main/java/Johan/rakendus.java @@ -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 \ No newline at end of file diff --git a/src/main/java/Johan/ruumala.java b/src/main/java/Johan/ruumala.java new file mode 100644 index 0000000..3096729 --- /dev/null +++ b/src/main/java/Johan/ruumala.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/Johan/silinder.java b/src/main/java/Johan/silinder.java new file mode 100644 index 0000000..001e647 --- /dev/null +++ b/src/main/java/Johan/silinder.java @@ -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) ; + } +} \ No newline at end of file diff --git a/src/main/resources/public/arvutus.html b/src/main/resources/public/arvutus.html new file mode 100644 index 0000000..2dbf89f --- /dev/null +++ b/src/main/resources/public/arvutus.html @@ -0,0 +1,33 @@ + + + + + + +

Silindri ruumala arvutamine

+

+ Sisesta silindri kõrgus
+
+ Sisesta silindri põhja raadius
+ +
+ +

+
Vastus:
+ + \ No newline at end of file diff --git a/src/test/Johan/pindalaTest.java b/src/test/Johan/pindalaTest.java new file mode 100644 index 0000000..09e3ca7 --- /dev/null +++ b/src/test/Johan/pindalaTest.java @@ -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 pindalaTest{ + @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); + } + } \ No newline at end of file diff --git a/target/classes/Johan/rakendus.class b/target/classes/Johan/rakendus.class new file mode 100644 index 0000000000000000000000000000000000000000..b72d74e09650c3288147e5132da47a0ae6e89b39 GIT binary patch literal 1561 zcmb7ETXPdP6#kUh-o)92#JLfmU@k4T3t6B*1Ezr_hBnj?8h6YvJjsq?MAj=;s|{s_ z9|bQ-24?sH{ZSo`);2bU*}rdd2cagUdWIDs$Zg(85|u&ZSHf1g+irLtPUvDjFv%*LYB6pz{s|!%TQ9v zwIEQ28>s@yxKdTR<%Jy^x~q9xyi$74dnFoPLk2q@{~YUWi+>^!nn%3T>84HZb3Y=& z<6bCz3KrVI{AXkOYgx=;(TY9JkhTo#4o)yEe$8_|l0Kyv!zqTjTAWbJd{10n1^FzN zaM~t1!!Td?R%fwpq0YKEhx6oX7hlWmzCBccip}w(i=S|jDnml3bPT5o3AXjy=S0Rq|eA$f8wTnMdC1@RyyUhgXB)=0cLQ|0^ z{~B*Y1-r5pX?rDyfN0rnQz=KeZZXUzBxcCgRHU2Yfwb3qvj1W%Thka;6LDi*JTi(1 z#K5Aba-9SZ5g_F6xxt~ajJ5K8q02Z6;!RH)sHMw^47Co;Jn9+s>Cz#_-qBzLS!(Sz zFpddo-EIK&lQg4Ck7E=yP2(w=&Cr*74i;iIPUzFW8QRN#z}&No#X~IIPJh7Cv)su; z{IHZhK>h$14p4YYFxC16+4k58M9cRcVr-P5s&bgfJU$tw@+f3 Lmf&AB-v&Mbibaj0 literal 0 HcmV?d00001 diff --git a/target/classes/Johan/ruumala.class b/target/classes/Johan/ruumala.class new file mode 100644 index 0000000000000000000000000000000000000000..3eaf30ff6c19f025b4f922a8cc24ce8f8daf3db0 GIT binary patch literal 459 zcmY*V%TB^T6g@)=wY5A%(D;rkfrTWlOf<$s!om=ZXxIoN+5d~4rNe};&>u`X~7gIjO2r?`!X2Rue&3! zHxm#;MnfQTssc4T6EG`{YKO-~*!LV5SaxB-6)-B*jtzmFi!?F<`IZX2t9a7&qC463 zJ%M5?>`A{PBcrG;Hs^b2CqGp_JCSNH>}SsH z-H)4}$32G@HeHlZ7I1FEIO=&#rMJ7uLl5;E&3)1geuiMsF0;YAg(YU2Rg<;Go!UF& z;1$_tRw?9}b8{pOlXEs_3hb>BBO5Cy^3=CgqJn=)C#(e-mu zlsNhD;KI(%yqS5tx8FaXUjPo!GErctTtvPIdvh7caO^1)I)js8DvqZj5DZMwbs3Cf z8Op^8L$U3;odJV>7L7d%8f*>|oPajrWe_b#5e7rGFGKGto(?^ACx(H?Q13@05e$Tq zNu7iG!k2S~TK~VABL-6mF_tkkjfY50l7!#La3W` + + + + + +

Silindri ruumala arvutamine

+

+ Sisesta silindri kõrgus
+
+ Sisesta silindri põhja raadius
+ +
+ +

+
Vastus:
+ + \ No newline at end of file From ba191d7359b9ce8367e1b9cb9ab74de8a3457033 Mon Sep 17 00:00:00 2001 From: ciruss Date: Tue, 30 May 2017 14:46:26 +0300 Subject: [PATCH 2/2] midagi veel --- .classpath | 5 +++++ .settings/org.eclipse.core.resources.prefs | 1 + src/test/Johan/{pindalaTest.java => rakendusTest.java} | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) rename src/test/Johan/{pindalaTest.java => rakendusTest.java} (96%) diff --git a/.classpath b/.classpath index fd7ad7f..f6795bd 100644 --- a/.classpath +++ b/.classpath @@ -22,5 +22,10 @@ + + + + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index e9441bb..abdea9a 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ eclipse.preferences.version=1 encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 encoding/=UTF-8 diff --git a/src/test/Johan/pindalaTest.java b/src/test/Johan/rakendusTest.java similarity index 96% rename from src/test/Johan/pindalaTest.java rename to src/test/Johan/rakendusTest.java index 09e3ca7..dd3246a 100644 --- a/src/test/Johan/pindalaTest.java +++ b/src/test/Johan/rakendusTest.java @@ -13,7 +13,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) - public class pindalaTest{ + public class rakendusTest{ @Autowired private TestRestTemplate restTemplate;