less & equals
This commit is contained in:
parent
aa8c2786d4
commit
f754db609d
|
@ -1 +1,2 @@
|
|||
Java_2.iml
|
||||
Java_2.iml
|
||||
target
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="9.0" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-surefire-provider:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-launcher:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apache.maven.surefire:surefire-api:2.19.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apache.maven.surefire:common-java5:2.19.1" level="project" />
|
||||
</component>
|
||||
</module>
|
9
pom.xml
9
pom.xml
|
@ -8,5 +8,14 @@
|
|||
<artifactId>java2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-surefire-provider</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,97 @@
|
|||
package de.joethei.hs.java2.praktikum1;
|
||||
|
||||
|
||||
public class GrosseZahl {
|
||||
int Zahl[];
|
||||
|
||||
GrosseZahl(String d) {
|
||||
Boolean korrekteEingabe=true;
|
||||
for(int i=0; i<d.length(); i++) {
|
||||
if(Integer.parseInt(String.valueOf(d.charAt(i))) < 0 || Integer.parseInt(String.valueOf(d.charAt(i))) > 9) {
|
||||
korrekteEingabe = false;
|
||||
}
|
||||
}
|
||||
if(korrekteEingabe) {
|
||||
Zahl = new int[d.length()];
|
||||
for(int w=0; w<d.length(); w++) {
|
||||
Zahl[w] = Integer.parseInt(String.valueOf(d.charAt(w)));
|
||||
}
|
||||
|
||||
} else {
|
||||
System.out.println("Incorrect Input!");
|
||||
}
|
||||
}
|
||||
|
||||
GrosseZahl(int i) {
|
||||
String intZahl = Integer.toString(i);
|
||||
Zahl = new int[intZahl.length()];
|
||||
for(int w=0; w<intZahl.length(); w++) {
|
||||
Zahl[w] = Integer.parseInt(String.valueOf(intZahl.charAt(w)));
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String rueckgabe = "";
|
||||
for(int i=0; i<Zahl.length; i++) {
|
||||
rueckgabe += Integer.toString(Zahl[i]);
|
||||
}
|
||||
return rueckgabe;
|
||||
}
|
||||
|
||||
private int toInt() {
|
||||
int IntZahl = 0;
|
||||
for(int i=0; i<Zahl.length; i++) {
|
||||
IntZahl *= 10;
|
||||
IntZahl += Zahl[i];
|
||||
}
|
||||
return IntZahl;
|
||||
}
|
||||
|
||||
boolean less(GrosseZahl b) {
|
||||
int ZahlEins = toInt(), ZahlZwei = b.toInt();
|
||||
if(ZahlEins < ZahlZwei) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
GrosseZahl add(GrosseZahl b) {
|
||||
int IntZahl = 0;
|
||||
for(int i=0; i<Zahl.length; i++) {
|
||||
IntZahl *= 10;
|
||||
IntZahl += Zahl[i];
|
||||
}
|
||||
IntZahl += b.toInt();
|
||||
GrosseZahl rueckgabe = new GrosseZahl(IntZahl);
|
||||
return rueckgabe;
|
||||
}
|
||||
|
||||
GrosseZahl mult(GrosseZahl b) {
|
||||
int IntZahl = 0;
|
||||
for(int i=0; i<Zahl.length; i++) {
|
||||
IntZahl *= 10;
|
||||
IntZahl += Zahl[i];
|
||||
}
|
||||
IntZahl *= b.toInt();
|
||||
GrosseZahl rueckgabe = new GrosseZahl(IntZahl);
|
||||
return rueckgabe;
|
||||
}
|
||||
|
||||
GrosseZahl ggT(GrosseZahl b) {
|
||||
int IntZahl = 0;
|
||||
for(int i=0; i<Zahl.length; i++) {
|
||||
IntZahl *= 10;
|
||||
IntZahl += Zahl[i];
|
||||
}
|
||||
if(IntZahl == b.toInt()) {
|
||||
return b;
|
||||
} else if(this.less(b)) {
|
||||
GrosseZahl c = new GrosseZahl(b.toInt()-IntZahl);
|
||||
return this.ggT(c);
|
||||
} else {
|
||||
GrosseZahl c = new GrosseZahl(IntZahl - b.toInt());
|
||||
return c.ggT(b);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue