Christian Baltzer
5 years ago
57 changed files with 3904 additions and 11 deletions
-
0Data.txt
-
13pom.xml
-
BINsrc/main/java/com/.DS_Store
-
BINsrc/main/java/com/ugsbo/.DS_Store
-
22src/main/java/com/ugsbo/Crypto/Crypto_Logic.java
-
92src/main/java/com/ugsbo/Crypto/Payload.java
-
36src/main/java/com/ugsbo/FirewallOfDeath/GrundFunktion.java
-
40src/main/java/com/ugsbo/FirewallOfDeath/NetzFunktion.java
-
29src/main/java/com/ugsbo/IsMyComputerOn/IsMyComputerOn_App.java
-
33src/main/java/com/ugsbo/VokableKartenSchreiber/VokabelKartenSchreiber.java
-
91src/main/java/com/ugsbo/VokableKartenSchreiber/Vokabelkarte.java
-
67src/main/java/com/ugsbo/VokableKartenSchreiber/VokabelnwithTerminal.java
-
45src/main/java/com/ugsbo/auslandssemester/AuslandssemesterMain.java
-
180src/main/java/com/ugsbo/auslandssemester/Sitzung.java
-
156src/main/java/com/ugsbo/complexnumcalc/ComplexNumber.java
-
192src/main/java/com/ugsbo/entscheider/Entscheider.java
-
8src/main/java/com/ugsbo/entscheider/package-info.java
-
46src/main/java/com/ugsbo/gui/BasicGuiController.java
-
73src/main/java/com/ugsbo/gui/MainApp.java
-
8src/main/java/com/ugsbo/gui/StartApplication.java
-
273src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java
-
97src/main/java/com/ugsbo/matrixcalc/MatrixCalcIOUtils.java
-
228src/main/java/com/ugsbo/matrixcalc/MatrixCalcMath.java
-
8src/main/java/module-info.java
-
15src/main/java/ugsbo/com/buchhaltung/Auswertung.java
-
67src/main/java/ugsbo/com/buchhaltung/Block.java
-
32src/main/java/ugsbo/com/buchhaltung/Blockchain.java
-
15src/main/java/ugsbo/com/notenSpeicher/Auswertung.java
-
77src/main/java/ugsbo/com/notenSpeicher/Noten.java
-
38src/main/java/ugsbo/com/notenSpeicher/NotenKette.java
-
41src/main/resources/com/ugsbo/gui/BasicGui.fxml
-
35src/main/resources/com/ugsbo/gui/Voabelkartenschreiber.fxml
-
37src/main/resources/com/ugsbo/gui/matrixCalcGui.fxml
-
4src/main/resources/com/ugsbo/gui/styles.css
-
63src/test/java/com/ugsbo/Buchhaltung/Test_Blockchain.java
-
66src/test/java/com/ugsbo/Crypto/Crypt.java
-
62src/test/java/com/ugsbo/Crypto/DeCrypt.java
-
20src/test/java/com/ugsbo/FirewallOfDeath/UselessTest.java
-
21src/test/java/com/ugsbo/IsMyComputerOn/IstErAn.java
-
62src/test/java/com/ugsbo/VokabelKartenSchreiber/NichtLeeralsohinzufügenTest.java
-
108src/test/java/com/ugsbo/VokabelKartenSchreiber/makeStringTest.java
-
421src/test/java/com/ugsbo/auslandssemester/JUnitTestAusslandssemesterSitzung.java
-
71src/test/java/com/ugsbo/complexnumcalc/AbsoluteValueOfComplexNumbersTest.java
-
31src/test/java/com/ugsbo/complexnumcalc/AddComplexNumbersTest.java
-
31src/test/java/com/ugsbo/complexnumcalc/DivideComplexNumbersTest.java
-
69src/test/java/com/ugsbo/complexnumcalc/EqualsComplexNumbersTest.java
-
31src/test/java/com/ugsbo/complexnumcalc/MultiplyComplexNumbersTest.java
-
31src/test/java/com/ugsbo/complexnumcalc/SubstractComplexNumbersTest.java
-
33src/test/java/com/ugsbo/complexnumcalc/conjugationOfComplexNumbersTest.java
-
80src/test/java/com/ugsbo/entscheider/JUnitEntscheiderErgebnisTest.java
-
1src/test/java/com/ugsbo/entscheider/package-info.java
-
156src/test/java/com/ugsbo/matrixcalc/MatrixAdditionAndSubstractionTest.java
-
61src/test/java/com/ugsbo/matrixcalc/MatrixCalcDeterminatTest.java
-
170src/test/java/com/ugsbo/matrixcalc/MatrixIOUtilsTest.java
-
109src/test/java/com/ugsbo/matrixcalc/MatrixMultiplicationTest.java
-
57src/test/java/com/ugsbo/matrixcalc/MatrixTransposeTest.java
-
63src/test/java/com/ugsbo/notenSpeicher/Test_NotenChain.java
@ -0,0 +1,22 @@ |
|||
package com.ugsbo.Crypto; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.security.GeneralSecurityException; |
|||
|
|||
public class Crypto_Logic { |
|||
|
|||
public static void main(String[] args) throws UnsupportedEncodingException, GeneralSecurityException { |
|||
// TODO Auto-generated method stub |
|||
String test = "Hallo, mein Name ist Christian"; |
|||
|
|||
Payload temp = new Payload(); |
|||
temp.setOffen(test); |
|||
temp.setPassword("geheim"); |
|||
temp.verschlüsseln(); |
|||
System.out.println(temp.getVerschlüsselt()); |
|||
|
|||
temp.entschlüsseln(); |
|||
System.out.println(temp.getOffen()); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,92 @@ |
|||
package com.ugsbo.Crypto; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.security.GeneralSecurityException; |
|||
import java.security.MessageDigest; |
|||
import java.security.NoSuchAlgorithmException; |
|||
import java.util.Arrays; |
|||
import java.util.Base64; |
|||
import javax.crypto.*; |
|||
import javax.crypto.spec.SecretKeySpec; |
|||
|
|||
|
|||
public class Payload { |
|||
|
|||
String offen; |
|||
String verschlüsselt; |
|||
SecretKeySpec password; |
|||
|
|||
public Payload() { |
|||
offen = ""; |
|||
verschlüsselt = ""; |
|||
|
|||
try { |
|||
this.setPassword(""); |
|||
} catch (UnsupportedEncodingException e) { |
|||
// TODO Auto-generated catch block |
|||
e.printStackTrace(); |
|||
} catch (GeneralSecurityException e) { |
|||
// TODO Auto-generated catch block |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
|
|||
public String getOffen() { |
|||
return offen; |
|||
} |
|||
|
|||
|
|||
|
|||
public String getVerschlüsselt() { |
|||
return verschlüsselt; |
|||
} |
|||
|
|||
public void setOffen(String offen) { |
|||
this.offen = offen; |
|||
} |
|||
|
|||
|
|||
|
|||
public void setVerschlüsselt(String verschlüsselt) { |
|||
this.verschlüsselt = verschlüsselt; |
|||
} |
|||
|
|||
|
|||
|
|||
public void setPassword(String password) |
|||
throws GeneralSecurityException, UnsupportedEncodingException { |
|||
byte[] key = (password).getBytes("UTF-8"); |
|||
|
|||
// aus dem Array einen Hash-Wert erzeugen mit MD5 oder SHA |
|||
MessageDigest sha = MessageDigest.getInstance("SHA-256"); |
|||
key = sha.digest(key); |
|||
|
|||
// nur die ersten 128 bit nutzen |
|||
key = Arrays.copyOf(key, 16); |
|||
|
|||
// der fertige Schluessel |
|||
this.password = new SecretKeySpec(key, "AES"); |
|||
} |
|||
|
|||
|
|||
|
|||
public void verschlüsseln() throws NoSuchAlgorithmException, GeneralSecurityException { |
|||
Cipher cipher = Cipher.getInstance("AES"); |
|||
cipher.init(Cipher.ENCRYPT_MODE, password); |
|||
byte[] encrypted = cipher.doFinal(offen.getBytes()); |
|||
|
|||
verschlüsselt = Base64.getEncoder().encodeToString(encrypted); |
|||
} |
|||
|
|||
public void entschlüsseln() throws NoSuchAlgorithmException, GeneralSecurityException { |
|||
byte[] text = Base64.getDecoder().decode(verschlüsselt); |
|||
|
|||
Cipher cipher = Cipher.getInstance("AES"); |
|||
cipher.init(Cipher.DECRYPT_MODE, password); |
|||
byte[] cipherData2 = cipher.doFinal(text); |
|||
offen = new String(cipherData2); |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.ugsbo.FirewallOfDeath; |
|||
|
|||
import java.io.IOException; |
|||
import java.net.UnknownHostException; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
/*** |
|||
* In manchen Ländern gibt es keinen freien zugang zum Internett. Zum Glück gibt es VPN, diese haben aber die doofe Eigenschaft zusammenzubrechen. |
|||
* Praktischerweise sind in diesen Ländern meist alle Dienste von Google gesperrt, weswegen wir am Ping sehen können ob wir noch geschützt sind oder nicht. |
|||
* @author Christian |
|||
*/ |
|||
|
|||
public class GrundFunktion { |
|||
|
|||
public static void main(String[] args) throws InterruptedException { |
|||
// TODO Auto-generated method stub |
|||
while (true) { |
|||
try { |
|||
if (NetzFunktion.pingTogoogle()) { |
|||
System.out.println("alles gut"); |
|||
|
|||
}else { |
|||
System.out.println("PRÜFE SOFORT DEINEN VPN!!!"); |
|||
} |
|||
TimeUnit.MINUTES.sleep(1); |
|||
} |
|||
catch (UnknownHostException e) { |
|||
// TODO Auto-generated catch block |
|||
e.printStackTrace(); |
|||
} catch (IOException e) { |
|||
// TODO Auto-generated catch block |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,40 @@ |
|||
package com.ugsbo.FirewallOfDeath; |
|||
|
|||
import java.io.IOException; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.UnknownHostException; |
|||
|
|||
class NetzFunktion { |
|||
|
|||
/*** |
|||
* sendet einen Ping an google |
|||
* @return boolean können wir google erreichen oder nicht? |
|||
* @throws IOException |
|||
* @throws UnknownHostException |
|||
*/ |
|||
|
|||
public static boolean pingTogoogle() throws IOException,UnknownHostException { |
|||
//Googel IP adresse |
|||
try { |
|||
URL url = new URL("http://www.google.com"); |
|||
|
|||
//open a connection to that source |
|||
HttpURLConnection urlConnect = (HttpURLConnection)url.openConnection(); |
|||
|
|||
|
|||
//Gibt es keine Verbindung schlägt diese Zeile fehl. |
|||
@SuppressWarnings("unused") |
|||
Object objData = urlConnect.getContent(); |
|||
|
|||
}catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
return true; |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,29 @@ |
|||
package com.ugsbo.IsMyComputerOn; |
|||
|
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
public class IsMyComputerOn_App { |
|||
|
|||
public static void main(String[] args) { |
|||
while (true) { |
|||
System.out.print("Dein Rechner ist: "); |
|||
System.out.println((IstErAn()?"AN":"AUS")); |
|||
try { |
|||
TimeUnit.MINUTES.sleep(1); |
|||
} catch (InterruptedException e) { |
|||
// TODO Auto-generated catch block |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/*** |
|||
* |
|||
* @return true Da wir davon ausgehen, dass das Program nur ausgeführt werden kann wenn der Rechner läuft, geben wir immer true zurück. |
|||
*/ |
|||
|
|||
public static boolean IstErAn() { |
|||
// TODO Auto-generated method stub |
|||
return true; |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.ugsbo.VokableKartenSchreiber; |
|||
|
|||
import javafx.fxml.FXML; |
|||
import javafx.scene.control.*; |
|||
|
|||
|
|||
class VokabelKartenSchreiber{ |
|||
|
|||
@FXML |
|||
private static TextField Text_Name, Text_Frage, Text_Antwort1, Text_Antwort2, Text_Antwort3, Text_Antwort4; |
|||
|
|||
|
|||
public static void main(String[] args) { |
|||
|
|||
|
|||
} |
|||
|
|||
public static void button_absenden_pressed(){ |
|||
Vokabelkarte temp = new Vokabelkarte(); |
|||
|
|||
temp.makeString(Text_Name.getText(), Text_Frage.getText(), Text_Antwort1.getText(), Text_Antwort2.getText(), Text_Antwort3.getText(), Text_Antwort4.getText()); |
|||
|
|||
} |
|||
|
|||
/*** |
|||
* Falls die Gui nicht ganz funktioniert, hier eine Version die per Terminal gesteuert wird |
|||
*/ |
|||
|
|||
public static void TerminalVersion() { |
|||
VokabelnwithTerminal.start(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,91 @@ |
|||
package com.ugsbo.VokableKartenSchreiber; |
|||
|
|||
import java.io.BufferedWriter; |
|||
import java.io.FileWriter; |
|||
import java.util.Scanner; |
|||
|
|||
public class Vokabelkarte{ |
|||
String Name; |
|||
String Frage; |
|||
String Antwort1; |
|||
String Antwort2; |
|||
String Antwort3; |
|||
String Antwort4; |
|||
|
|||
String Ergebnis; |
|||
|
|||
Scanner sc; |
|||
BufferedWriter bw; |
|||
|
|||
|
|||
|
|||
/** |
|||
* @param sc |
|||
* @param bw |
|||
*/ |
|||
public Vokabelkarte() { |
|||
this.sc = new Scanner(System.in); |
|||
|
|||
try { |
|||
this.bw = new BufferedWriter(new FileWriter("Data.txt", true)); |
|||
} catch (Exception e) { |
|||
System.out.println("ne, wir nichts"); |
|||
} |
|||
} |
|||
|
|||
/*** |
|||
* |
|||
* @param Zwischenwert fügt ein Zwischenstück zwischen den beiden Strings ein |
|||
* @param neuesWort Der zu prüfende String |
|||
* @param bisherigerString Der String an den angehängt werden soll |
|||
* @return Der fertige String |
|||
*/ |
|||
|
|||
|
|||
//------------------------------------------------- |
|||
//Private |
|||
public String NichtLeeralsohinzufügen(String bisherigerString, String neuesWort, String Zwischenwert) { |
|||
if (!neuesWort.equals("")) { |
|||
neuesWort += Zwischenwert; |
|||
} |
|||
bisherigerString += neuesWort; |
|||
return bisherigerString; |
|||
} |
|||
|
|||
//------------------------------------------------- |
|||
//Public |
|||
|
|||
/*** |
|||
* Schreibt den Ergebnis String in eine Datei |
|||
*/ |
|||
public void schreiben() { |
|||
String Text = this.Ergebnis; |
|||
System.out.println(Text); |
|||
try { |
|||
bw.write(Text); |
|||
bw.write("\n"); |
|||
bw.flush(); |
|||
} catch (Exception e) { |
|||
System.out.println("AHHHHHHHHH"); |
|||
} |
|||
|
|||
} |
|||
|
|||
/*** |
|||
* Erstellt aus den Eingetragenen Feldern den endgüligen String im gültigen Format |
|||
* Muster: Name/Frage/Antwort;Antwort |
|||
* @return gibt den formatierten String zurück |
|||
*/ |
|||
public String makeString(String Name,String Frage,String Antwort1,String Antwort2,String Antwort3,String Antwort4) { |
|||
String Ergebnis = ""; |
|||
Ergebnis = NichtLeeralsohinzufügen(Ergebnis, Name, "/"); |
|||
Ergebnis = NichtLeeralsohinzufügen(Ergebnis, Frage, "/"); |
|||
Ergebnis = NichtLeeralsohinzufügen(Ergebnis, Antwort1, ";"); |
|||
Ergebnis = NichtLeeralsohinzufügen(Ergebnis, Antwort2, ";"); |
|||
Ergebnis = NichtLeeralsohinzufügen(Ergebnis, Antwort3, ";"); |
|||
Ergebnis = NichtLeeralsohinzufügen(Ergebnis, Antwort4, ""); |
|||
this.Ergebnis = Ergebnis; |
|||
return Ergebnis; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
package com.ugsbo.VokableKartenSchreiber; |
|||
|
|||
import java.io.*; |
|||
import java.util.Scanner; |
|||
|
|||
public class VokabelnwithTerminal{ |
|||
|
|||
public static Scanner sc = new Scanner(System.in); |
|||
public static BufferedWriter bw; |
|||
|
|||
//Liest die Daten von der Tastatur ein und gibt Sie weiter |
|||
public static void start() { |
|||
System.out.println("Willkommen!\nBitte trage deine Karten in der Form Name, Frage, Antwort 1 und Antwort 2 ein. \nGibt es keine zweite Antwort, so lassen Sie das Feld frei."); |
|||
|
|||
try { |
|||
bw = new BufferedWriter(new FileWriter("Data.txt", true)); |
|||
} catch (Exception e) { |
|||
System.out.println("ne, wir nichts"); |
|||
} |
|||
|
|||
while (true){ |
|||
String Temp_String = ""; |
|||
System.out.println("---------------------------------------------------------------"); |
|||
System.out.println("Name?"); |
|||
String Name = sc.nextLine(); |
|||
if(!Name.isEmpty()){ |
|||
Temp_String += Name; |
|||
Temp_String += "/"; |
|||
} |
|||
|
|||
|
|||
System.out.println("Frage?"); |
|||
Temp_String += sc.nextLine(); |
|||
Temp_String += "/"; |
|||
|
|||
|
|||
System.out.println("Antwort?"); |
|||
String Antwort = ""; |
|||
Temp_String += sc.nextLine(); |
|||
|
|||
while(true){ |
|||
System.out.println("nächste Antwort"); |
|||
Antwort = sc.nextLine(); |
|||
if (Antwort.isEmpty()){ |
|||
break; |
|||
} |
|||
Temp_String += ";" + Antwort; |
|||
} |
|||
Speichern(Temp_String); |
|||
} |
|||
} |
|||
|
|||
// Schreibt den übergebenen String in die Datei |
|||
|
|||
public static void Speichern(String Text) { |
|||
|
|||
System.out.println(Text); |
|||
try { |
|||
bw.write(Text); |
|||
bw.write("\n"); |
|||
bw.flush(); |
|||
} catch (Exception e) { |
|||
System.out.println("AHHHHHHHHH"); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.ugsbo.auslandssemester; |
|||
|
|||
import java.util.Scanner; |
|||
|
|||
public class AuslandssemesterMain { |
|||
|
|||
public static void main(String[] args) { |
|||
// TODO Auto-generated method stub |
|||
Scanner in = new Scanner(System.in); |
|||
System.out.println("Bitte gebe deinen Nachnamen ein."); |
|||
String name = in.nextLine(); |
|||
System.out.println("Bitte gebe deinen Vornamen ein."); |
|||
String vorname = in.nextLine(); |
|||
|
|||
System.out |
|||
.println("Bitte schreibe auf ob du nach Europa, Australien, Neuseeland, Asien oder in die USA gehst."); |
|||
String destination = in.nextLine(); |
|||
if (!(destination.equals("Europa")) && !(destination.equals("Australien")) && !(destination.equals("Neuseeland")) && !(destination.equals("Asien")) && !(destination.equals("USA")) ) { |
|||
System.out.println("Plaese Start Again. falsche Eingabe."); |
|||
} else { |
|||
System.out.println("Sage mir bitte in wie vielen Monaten du ins Ausland moechtest?"); |
|||
int inMonaten = in.nextInt(); |
|||
System.out.println("Danke"); |
|||
Sitzung g = new Sitzung(name, vorname, inMonaten, destination); |
|||
|
|||
System.out.println("Tipp 1:"); |
|||
System.out.println(g.deadline(g.kategorieInMonaten(), g.kategorieDestination())); |
|||
|
|||
System.out.println("Tipp 2:"); |
|||
System.out.println(g.finanzierung(g.kategorieInMonaten(), g.kategorieDestination())); |
|||
|
|||
|
|||
System.out.println("Tipp 4:"); |
|||
System.out.println(g.learningAgreement(g.kategorieInMonaten())); |
|||
|
|||
|
|||
System.out.println("Tipp 3:"); |
|||
System.out.println(g.wohnen(g.kategorieInMonaten())); |
|||
|
|||
System.out.println("Tipp 3:"); |
|||
System.out.println(g.packen(g.kategorieInMonaten())); |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,180 @@ |
|||
package com.ugsbo.auslandssemester; |
|||
|
|||
public class Sitzung { |
|||
private String name; |
|||
private String vorname; |
|||
private int inMonaten; |
|||
private String destination; |
|||
|
|||
// Konstruktor mit Übergabewerten |
|||
public Sitzung(String nachname, String vor, int monate, String ziel) { |
|||
this.name = nachname; |
|||
this.vorname = vor; |
|||
this.inMonaten = monate; |
|||
this.destination = ziel; |
|||
} |
|||
|
|||
public String kategorieDestination() { |
|||
String kategorie = "Europa"; |
|||
if (destination == "Australien" || destination == "Neuseeland" || destination == "Asien") { |
|||
kategorie = "Asien"; |
|||
} |
|||
if (destination == "USA") { |
|||
kategorie = "USA"; |
|||
} |
|||
return kategorie; |
|||
} |
|||
|
|||
public int kategorieInMonaten() { |
|||
int kategorie = 4; // alles was größer als 12 Monate ist |
|||
|
|||
if (inMonaten <= 2) { |
|||
kategorie = 1; |
|||
} |
|||
if (inMonaten > 2 && inMonaten <= 5) { |
|||
kategorie = 2; |
|||
} |
|||
if (inMonaten > 5 && inMonaten <= 12) { |
|||
kategorie = 3; |
|||
} |
|||
|
|||
return kategorie; |
|||
} |
|||
// tipps |
|||
|
|||
// tipp zum learning Agreement |
|||
|
|||
public String learningAgreement(int kategorieZeit) { |
|||
String tipp = "kein Tipp."; |
|||
if (kategorieZeit == 4 || kategorieZeit == 3) { |
|||
tipp = "Jetzt musst du dich noch nicht über das Learning Agreement informieren."; |
|||
} |
|||
|
|||
if (kategorieZeit == 2) { |
|||
tipp = "Jetzt solltest du dich über das Learning Agreement informieren. Was musst du wissen? Wer muss es unterzeichnen? Wo musst du es abgeben?"; |
|||
} |
|||
if (kategorieZeit == 1) { |
|||
tipp = "Wenn du jetzt noch kein Learning Agreement hast ist das seltsam. Frag so schnell es geht mal jemanden ob du eins brauchst."; |
|||
} |
|||
return tipp; |
|||
|
|||
} |
|||
|
|||
public String packen(int kategorieZeit) { |
|||
String tipp = "kein Tipp."; |
|||
if (kategorieZeit == 4 || kategorieZeit == 3) { |
|||
tipp = "Kein Stress. DU hast noch eine Ewigkeit Zeit zum packen."; |
|||
} |
|||
|
|||
if (kategorieZeit == 2) { |
|||
tipp = "Wenn du magst kannst schonmal anfangen eine Liste zu schreiben."; |
|||
} |
|||
if (kategorieZeit == 1) { |
|||
tipp = "Jetzt solltest du definitiv eine Liste schreiben und so langsam mal anfangen."; |
|||
} |
|||
return tipp; |
|||
|
|||
} |
|||
|
|||
// neuer Tipp zu den Deadlines |
|||
|
|||
public String deadline(int kategorieZeit, String kategorieZiel) { |
|||
String tipp = "kein Tipp"; |
|||
if (kategorieZiel == "USA" || kategorieZiel == "Asien") { |
|||
if (kategorieZeit == 4) { |
|||
tipp = "Zu diesem Zeitraum ist es sinnvoll sich über die entsprechenden Deadlines zu informieren."; |
|||
} |
|||
|
|||
if (kategorieZeit == 3) { |
|||
tipp = "Jetzt solltest du dich auf jeden Fall über die Deadlines informieren."; |
|||
} |
|||
|
|||
if (kategorieZeit == 2) { |
|||
tipp = "Die Bewerbungsdeadlines sind hier wahrscheinlich schon durch. Stipendien könnten aber noch gehen"; |
|||
} |
|||
if (kategorieZeit == 1) { |
|||
tipp = "Es tut mir Leid, aber du bist zu spät dran. Alle Deadlines sind durch."; |
|||
} |
|||
|
|||
} else { |
|||
if (kategorieZeit == 4) { |
|||
tipp = "Zu diesem Zeitpunkt musst du dich noch nicht um Deadlines sorgen. Mal schauen schadet aber nicht."; |
|||
} |
|||
|
|||
if (kategorieZeit == 3) { |
|||
tipp = "Jetzt wäre es wichtig sich über Deadlines zu informieren."; |
|||
} |
|||
|
|||
if (kategorieZeit == 2) { |
|||
tipp = "Jetzt aber wirklich zügig. Die Deadlines sind bestimmt noch nicht ganz abgelaufen."; |
|||
} |
|||
if (kategorieZeit == 1) { |
|||
tipp = "Es tut mir Leid, aber du bist zu spät dran. Alle Deadlines sind durch."; |
|||
} |
|||
} |
|||
return tipp; |
|||
|
|||
} |
|||
|
|||
//neuer Tipp zur Finanzierung |
|||
|
|||
public String finanzierung(int kategorieZeit, String kategorieZiel) { |
|||
String tipp = "kein Tipp"; |
|||
if(kategorieZiel == "USA" || kategorieZiel == "Asien") { |
|||
if(kategorieZeit == 4) { |
|||
tipp = "Finanzierung ist keine leichte Sache, darüber kann man sich nie zu früh Gedanken machen. Stichwort: Stipendium."; |
|||
} |
|||
|
|||
if(kategorieZeit == 3) { |
|||
tipp = "Jetzt musst du auf jeden Fall überlegen wie du das finanziern willst. Sprich vielleicht mal mit deinen Eltern oder such nach Stipendien"; |
|||
} |
|||
|
|||
if(kategorieZeit == 2) { |
|||
tipp = "Wenn du dich noch nicht um die Finanzierung gekümmert hast, dann musst du dich jetzt aber ran halten."; |
|||
} |
|||
if(kategorieZeit == 1) { |
|||
tipp = "Selbst wenn du bisher noch gar nicht an die Finanzierung gedacht hast solltest du es jetzt tun. Besser spät als nie."; |
|||
} |
|||
|
|||
} else { |
|||
if(kategorieZeit == 4) { |
|||
tipp = "Über die Finanzierung kann man sich nie zu früh Gedanken machen. Aber bitte keine Hektik."; |
|||
} |
|||
|
|||
if(kategorieZeit == 3) { |
|||
tipp = "Denk am besten schon mal ein bisschen an die Finanzierung. Frag an ob Erasmus für dich in Frage kommt."; |
|||
} |
|||
|
|||
if(kategorieZeit == 2) { |
|||
tipp = "Wenn du dich auf Ersamus beworben hast dann solltest du demnächst deine Rückmeldung bekommen."; |
|||
} |
|||
if(kategorieZeit == 1) { |
|||
tipp = "Wenn du ein Erasmus+ STipendium bekommst, dann wirst du noch einen Englischtest absolvieren und einen Vertrag unterschreiben müssen. Denk auch an deine Immatrikulationsbescheingung."; |
|||
} |
|||
} |
|||
return tipp; |
|||
|
|||
} |
|||
|
|||
// neuer Tipp zum Wohnen |
|||
public String wohnen(int kategorieZeit) { |
|||
String tipp = "kein Tipp."; |
|||
if (kategorieZeit == 4) { |
|||
tipp = "Schau dich am besten schon mal nach Wohnungen um. Manchmal gibt es Webseiten auf denen man über die Zeit Punkte sammelt."; |
|||
} |
|||
|
|||
if (kategorieZeit == 3) { |
|||
tipp = "Jetzt informier dich definitiv schon mal wie es mit Wohnen ist. Manchmal gibt es Webseiten auf denen man über die Zeit Punkte sammelt."; |
|||
} |
|||
|
|||
if (kategorieZeit == 2) { |
|||
tipp = "Jetzt wird es höchste Zeit nach einer Wohung zu schauen."; |
|||
} |
|||
if (kategorieZeit == 1) { |
|||
tipp = "Jetzt ist es schon fast zu spät um nach einer Wohnung zu suchen"; |
|||
} |
|||
return tipp; |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,156 @@ |
|||
package com.ugsbo.complexnumcalc; |
|||
|
|||
public class ComplexNumber { |
|||
private Double realPart; |
|||
private Double imaginaryPart; |
|||
|
|||
/** |
|||
* @param realPart The real part of the complex Number |
|||
* @param imaginaryPart The imaginary part of the complex Number |
|||
*/ |
|||
|
|||
public ComplexNumber(Double realPart, Double imaginaryPart) { |
|||
this.realPart = realPart; |
|||
this.imaginaryPart = imaginaryPart; |
|||
} |
|||
|
|||
/** |
|||
* @return the realPart |
|||
*/ |
|||
public Double getRealPart() { |
|||
return realPart; |
|||
} |
|||
|
|||
/** |
|||
* @param realPart the realPart to set |
|||
*/ |
|||
public void setRealPart(Double realPart) { |
|||
this.realPart = realPart; |
|||
} |
|||
|
|||
/** |
|||
* @return the imaginaryPart |
|||
*/ |
|||
public Double getImaginaryPart() { |
|||
return imaginaryPart; |
|||
} |
|||
|
|||
/** |
|||
* @param imaginaryPart the imaginaryPart to set |
|||
*/ |
|||
public void setImaginaryPart(Double imaginaryPart) { |
|||
this.imaginaryPart = imaginaryPart; |
|||
} |
|||
|
|||
/** |
|||
* Checks if the given complex Number is equal to this object. |
|||
* |
|||
* @param complexNumber The number wich gets compared with this Instance |
|||
* @return True if the complex Numbers are Equal |
|||
*/ |
|||
@Override |
|||
public boolean equals(Object complexNumber) { |
|||
if (complexNumber instanceof ComplexNumber){ |
|||
ComplexNumber that = (ComplexNumber) complexNumber; |
|||
return this.realPart.equals(that.realPart) && this.imaginaryPart.equals(that.imaginaryPart); |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Adds two complex Numbers together. |
|||
* |
|||
* @param addend The complex Number. |
|||
* @return The result of adding the two complex Numbers together, as a conplex |
|||
* Number. |
|||
*/ |
|||
public ComplexNumber add(ComplexNumber addend) { |
|||
Double sumRealPart, sumImaginaryPart; |
|||
|
|||
sumRealPart = this.realPart + addend.realPart; |
|||
sumImaginaryPart = this.imaginaryPart + addend.imaginaryPart; |
|||
|
|||
ComplexNumber sum = new ComplexNumber(sumRealPart, sumImaginaryPart); |
|||
|
|||
return sum; |
|||
} |
|||
|
|||
/** |
|||
* Substracts the Subtrahend form this instance. |
|||
* |
|||
* @param subtrahend The Number wich will be substracted form the Minuend |
|||
* @return The Differenz of the Minuend and Subtrahend. |
|||
*/ |
|||
public ComplexNumber substract(ComplexNumber subtrahend) { |
|||
Double differenzRealPart, differenzImaginaryPart; |
|||
|
|||
differenzRealPart = this.realPart - subtrahend.realPart; |
|||
differenzImaginaryPart = this.imaginaryPart - subtrahend.imaginaryPart; |
|||
|
|||
ComplexNumber differenz = new ComplexNumber(differenzRealPart, differenzImaginaryPart); |
|||
|
|||
return differenz; |
|||
} |
|||
|
|||
/** |
|||
* Multiplies the faktor with this Instance. |
|||
* |
|||
* @param faktor The ComplexNumber by wich this Instance will get multiplyed |
|||
* @return The product of this Instance and the faktor |
|||
*/ |
|||
public ComplexNumber multiply(ComplexNumber faktor) { |
|||
Double productRealPart, productImaginaryPart; |
|||
|
|||
productRealPart = this.realPart * faktor.realPart - this.imaginaryPart * faktor.imaginaryPart; |
|||
productImaginaryPart = this.realPart * faktor.imaginaryPart + this.imaginaryPart * faktor.realPart; |
|||
|
|||
ComplexNumber product = new ComplexNumber(productRealPart, productImaginaryPart); |
|||
|
|||
return product; |
|||
} |
|||
|
|||
/** |
|||
* Divides the dividend by the divisor, the dividend is this Instance. |
|||
* |
|||
* @param divisor The ComplexNumber by wich this Instance will get divided |
|||
* @return The Qoutient of the Instance and the divisor |
|||
*/ |
|||
public ComplexNumber divide(ComplexNumber divisor) { |
|||
Double qoutientRealPart, qoutientImaginaryPart, tempDivisor; |
|||
|
|||
tempDivisor = divisor.realPart * divisor.realPart + divisor.imaginaryPart * divisor.imaginaryPart; |
|||
qoutientRealPart = this.realPart * divisor.realPart + this.imaginaryPart * divisor.imaginaryPart; |
|||
qoutientImaginaryPart = this.imaginaryPart * divisor.realPart - this.realPart * divisor.imaginaryPart; |
|||
qoutientImaginaryPart /= tempDivisor; |
|||
qoutientRealPart /= tempDivisor; |
|||
|
|||
ComplexNumber qoutient = new ComplexNumber(qoutientRealPart, qoutientImaginaryPart); |
|||
|
|||
return qoutient; |
|||
} |
|||
|
|||
/** |
|||
* Calucates the absolute value of this complex number |
|||
* @return the absolute value |
|||
*/ |
|||
public Double absolutValueOf(){ |
|||
Double absoluteValue = Math.sqrt(Math.pow(this.realPart, 2) + Math.pow(this.imaginaryPart, 2)) ; |
|||
return absoluteValue; |
|||
} |
|||
|
|||
/** |
|||
* Calucates the absolute value of this complex number |
|||
* @return the absolute value |
|||
*/ |
|||
public ComplexNumber conjugationOf(){ |
|||
if(this.imaginaryPart.equals(Double.valueOf(0))){ |
|||
return this; |
|||
} else { |
|||
this.imaginaryPart *= (-1); |
|||
return this; |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,192 @@ |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
package com.ugsbo.entscheider; |
|||
|
|||
import java.util.Scanner; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* @author bruec |
|||
* |
|||
*/ |
|||
public class Entscheider { |
|||
|
|||
/** |
|||
* @param args |
|||
*/ |
|||
public static void main(String[] args) { |
|||
System.out.println("Herzlich Willkommen!"); |
|||
String a = fragen(); |
|||
System.out.println(a); |
|||
if(a != "Na dann halt nicht. Tschüssi.") { |
|||
System.out.println("Auf Wiedersehen. Frag mich gerne nochmal wenn du mal wieder nicht weisst, ob du in die Vorlesung gehen solltest oder nicht."); |
|||
} |
|||
|
|||
} |
|||
//testbar |
|||
//Eingaben -> alter, lernen, gelb, apfel, mot, harry, fruehstueck, anzahl |
|||
public static String ergebnis(int alter, int lernen, int gelb, int apfel, int mot, int harry, int fruehstueck, int anzahl) { |
|||
int erg = (((alter + lernen + gelb) * apfel) / (mot + harry + fruehstueck)) - anzahl; |
|||
String hilfe = ""; |
|||
if (erg < 5) |
|||
hilfe = "Ich kann doch nicht fuer dich entscheiden, dass musst du schon selber wissen."; |
|||
if (erg >= 5 && erg < 15) |
|||
hilfe = "Naja, dann geh halt nach Hause und ruh dich aus."; |
|||
if (erg >= 15) |
|||
hilfe = "Jetzt wieder gehen? Dann bist du doch voellig umsonst aufgestanden. Geh einfach hin."; |
|||
|
|||
return hilfe; |
|||
} |
|||
//nicht testbar |
|||
public static String fragen() { |
|||
// Eingangsfrage |
|||
System.out.println( |
|||
"Du willst also wissen ob du in die Veranstaltung gehen sollst oder nicht? Gib 1 für Ja ein 0 für Nein."); |
|||
int a = getAnInteger(); |
|||
if (a == 1 || a == 0) { |
|||
if (a == 1) { |
|||
System.out.println("Dann werde ich dir jetzt ein paar Fragen stellen"); |
|||
} else { |
|||
return("Na dann halt nicht. Tschüssi."); |
|||
} |
|||
|
|||
} else { |
|||
a = pruefen(a); |
|||
if (a == 1) { |
|||
System.out.println("Dann werde ich dir jetzt ein paar Fragen stellen"); |
|||
} else { |
|||
return ("Na dann halt nicht. Tschüssi.") ; |
|||
} |
|||
|
|||
} |
|||
// zweite Frage |
|||
System.out.println("Wie alt bist du?"); |
|||
int alter = getAnInteger(); |
|||
if (alter > 0) { |
|||
System.out.println(alter); |
|||
} else { |
|||
while (alter <= 0) { |
|||
System.out.println("Versuches es nochmal. Du musst mindestens 1 sein."); |
|||
alter = getAnInteger(); |
|||
} |
|||
} |
|||
|
|||
// dritte Frage |
|||
System.out.println("Auf einer Skala von 1 bis 10 wie motiviert bist du?"); |
|||
int mot = getAnInteger(); |
|||
if (mot >= 1 && mot <= 10) { |
|||
System.out.println(mot); |
|||
} else { |
|||
mot = skalaTest(mot); |
|||
System.out.println(mot); |
|||
} |
|||
|
|||
// vierte Frage |
|||
System.out.println("Hast du gefrühstückt? Bei Ja bitte 1 und bei Nein bitte 0"); |
|||
int fruehstueck = getAnInteger(); |
|||
if (fruehstueck == 1 || fruehstueck == 0) { |
|||
System.out.println(fruehstueck); |
|||
} else { |
|||
fruehstueck = pruefen(fruehstueck); |
|||
System.out.println(fruehstueck); |
|||
} |
|||
|
|||
// fuenfte Frage |
|||
System.out.println("Hast du jemals ein Harry Potterbuch gelesen? Bei Ja bitte 1 und bei Nein bitte 0"); |
|||
int harry = getAnInteger(); |
|||
if (harry == 1 || harry == 0) { |
|||
System.out.println(harry); |
|||
} else { |
|||
harry = pruefen(harry); |
|||
System.out.println(harry); |
|||
} |
|||
|
|||
// sechste Frage |
|||
System.out.println("Wie viele Äpfel hast du heute schon gegessen?"); |
|||
int apfel = getAnInteger(); |
|||
if (apfel > 0) { |
|||
System.out.println(apfel); |
|||
} else { |
|||
while (apfel <= 0) { |
|||
System.out.println("Versuches es nochmal. Die Zahl muss positiv sein."); |
|||
apfel = getAnInteger(); |
|||
} |
|||
} |
|||
|
|||
// siebte Frage |
|||
System.out.println("Wie viele Veranstaltungen hattest du heute schon?"); |
|||
int anzahl = getAnInteger(); |
|||
if (anzahl > 0) { |
|||
System.out.println(anzahl); |
|||
} else { |
|||
while (anzahl <= 0) { |
|||
System.out.println("Versuches es nochmal. Die Zahl muss positiv sein."); |
|||
anzahl = getAnInteger(); |
|||
} |
|||
} |
|||
|
|||
// achte Frage |
|||
System.out.println("Was würdest du statt der Vorlesung machen? Lernen? Bei Ja bitte 1 und bei Nein bitte 0"); |
|||
int lernen = getAnInteger(); |
|||
if (lernen == 1 || lernen == 0) { |
|||
System.out.println(lernen); |
|||
} else { |
|||
lernen = pruefen(lernen); |
|||
System.out.println(lernen); |
|||
} |
|||
if (lernen == 1) |
|||
System.out.println("Wenn du das sagst, aber lueg dich doch bitte nicht selbst an."); |
|||
|
|||
// neunte Frage |
|||
System.out.println("Wuerdest du dir ein gelbes Auto kaufen? Bei Ja bitte 1 und bei Nein bitte 0"); |
|||
int gelb = getAnInteger(); |
|||
if (gelb == 1 || gelb == 0) { |
|||
System.out.println(gelb); |
|||
} else { |
|||
gelb = pruefen(gelb); |
|||
System.out.println(gelb); |
|||
} |
|||
|
|||
// Auswertung |
|||
|
|||
String antwort = ergebnis(alter, lernen, gelb, apfel, mot, harry, fruehstueck, anzahl); |
|||
return antwort; |
|||
|
|||
} |
|||
//nicht testbar |
|||
public static int skalaTest(int answer) { |
|||
System.out.println("Try again. Nur Werte zwischen 1 und 10 sind erlaubt."); |
|||
int b = getAnInteger(); |
|||
if (b >= 1 && b <= 10) { |
|||
return b; |
|||
} |
|||
skalaTest(b); |
|||
return -1; |
|||
} |
|||
//nicht testbar |
|||
public static int getAnInteger() { |
|||
Scanner in = new Scanner(System.in); |
|||
while (true) { |
|||
try { |
|||
return in.nextInt(); |
|||
} catch (InputMismatchException e) { |
|||
in.next(); |
|||
System.out.println("Das ist kein Integer. Try again."); |
|||
} |
|||
} |
|||
} |
|||
|
|||
//Nicht testbar |
|||
public static int pruefen(int answer) { |
|||
System.out.println("Try again. Nur 1 und 0 sind erlaubt."); |
|||
int b = getAnInteger(); |
|||
if (b == 1 || b == 0) { |
|||
return b; |
|||
} |
|||
pruefen(b); |
|||
return 1; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,8 @@ |
|||
/** |
|||
* |
|||
*/ |
|||
/** |
|||
* @author bruec |
|||
* |
|||
*/ |
|||
package com.ugsbo.entscheider; |
@ -0,0 +1,46 @@ |
|||
package com.ugsbo.gui; |
|||
|
|||
import javafx.fxml.FXML; |
|||
import javafx.scene.control.*; |
|||
|
|||
public class BasicGuiController { |
|||
|
|||
// Hier werden die fx:id Attribute verknuepft. |
|||
@FXML |
|||
private Button matrixCalc; |
|||
@FXML |
|||
private Button app2; //Fuer VokabelKartenSchreiber |
|||
@FXML |
|||
private Button app3; |
|||
@FXML |
|||
private Button app4; |
|||
|
|||
/** |
|||
* Konstructor is called before initialize() |
|||
*/ |
|||
public BasicGuiController() { |
|||
// Setup of some Fields could be defined here. |
|||
} |
|||
|
|||
/** |
|||
* Initializes the controller class. This method is automatically called after |
|||
* the fxml file has been loaded. |
|||
*/ |
|||
@FXML |
|||
public void initialize() { |
|||
matrixCalc.setOnMouseClicked((event) -> { |
|||
MainApp.startMatrixCalcGUI(); |
|||
// System.out.println(event); |
|||
}); |
|||
app2.setOnMouseClicked((event) -> { |
|||
//System.out.println(event); |
|||
MainApp.startVokabelKartenSchreiber(); |
|||
}); |
|||
app3.setOnMouseClicked((event) -> { |
|||
System.out.println(event); |
|||
}); |
|||
app4.setOnMouseClicked((event) -> { |
|||
System.out.println(event); |
|||
}); |
|||
} |
|||
} |
@ -1,8 +1,77 @@ |
|||
package com.ugsbo.gui; |
|||
|
|||
public class MainApp { |
|||
import java.io.IOException; |
|||
|
|||
import javafx.application.Application; |
|||
import javafx.fxml.FXMLLoader; |
|||
import javafx.scene.*; |
|||
import javafx.stage.Stage; |
|||
|
|||
/** |
|||
* Runs the main Application and handles the loading of an FXML file. |
|||
*/ |
|||
public class MainApp extends Application { |
|||
|
|||
/** |
|||
* The main() method is ignored in correctly deployed JavaFX application. main() |
|||
* serves only as fallback in case the application can not be launched through |
|||
* deployment artifacts, e.g., in IDEs with limited FX support. NetBeans ignores |
|||
* main(). |
|||
* |
|||
* @param args the command line arguments |
|||
*/ |
|||
public static void main(String[] args) { |
|||
System.out.println("HelloWorld!"); |
|||
launch(args); |
|||
} |
|||
|
|||
/** |
|||
* Starts the Main GUI, will be called from JavaFx. |
|||
*/ |
|||
@Override |
|||
public void start(Stage stage) { |
|||
createStageFromFXML(stage, "BasicGui"); |
|||
} |
|||
|
|||
/** |
|||
* Loades the FXML file and the Default CSS. |
|||
* |
|||
* @param stage The Stage will be passed over from JavaFx |
|||
* @param fxmlFileName Only the Filename of the fxml file wich sould be loaded |
|||
*/ |
|||
private void createStageFromFXML(Stage stage, String fxmlFileName) { |
|||
// Gettring the FXML loader to load the File. |
|||
FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFileName + ".fxml")); |
|||
Parent root; |
|||
// trying to load the FXML and CSS file for the GUI with the fxmlFileName. |
|||
try { |
|||
root = loader.load(); |
|||
Scene basicGUI = new Scene(root); |
|||
basicGUI.getStylesheets().add(getClass().getResource("styles.css").toExternalForm()); |
|||
// Setting the Title of the |
|||
stage.setTitle("Ultra geile Studenten Benutzeroberfläche"); |
|||
// set Resizeable to false, in oder to block resizeing though the User. |
|||
stage.setResizable(false); |
|||
stage.setScene(basicGUI); |
|||
} catch (IOException e) { |
|||
System.out.println(".FXML or .css File can not be found."); |
|||
e.printStackTrace(); |
|||
} |
|||
stage.show(); |
|||
} |
|||
|
|||
public static void startVokabelKartenSchreiber(){ |
|||
Stage stage = new Stage(); |
|||
MainApp main = new MainApp(); |
|||
main.createStageFromFXML(stage, "Voabelkartenschreiber"); |
|||
} |
|||
|
|||
/** |
|||
* Startet eine Instanz der MatrixCalcGui. |
|||
*/ |
|||
public static void startMatrixCalcGUI() { |
|||
Stage stage = new Stage(); |
|||
MainApp app = new MainApp(); |
|||
app.createStageFromFXML(stage, "matrixCalcGui"); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.ugsbo.gui; |
|||
|
|||
public class StartApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
MainApp.main(args); |
|||
} |
|||
} |
@ -0,0 +1,273 @@ |
|||
package com.ugsbo.matrixcalc; |
|||
|
|||
import javafx.fxml.FXML; |
|||
import javafx.scene.control.*; |
|||
import javafx.scene.text.Text; |
|||
import javafx.scene.text.TextAlignment; |
|||
|
|||
import java.util.ArrayList; |
|||
|
|||
public class MatrixCalcController { |
|||
|
|||
private static final String MULTIPLICATION_STRING = "multiplication"; |
|||
private static final String ADDITION_STRING = "addition"; |
|||
private static final String SUBSTRACTION_STRING = "substract"; |
|||
private static final String TRANPOSE_STRING = "transpose"; |
|||
private static final String CALCDETERMINAT_STRING = "calcDeterminate"; |
|||
|
|||
// The fx:id Attributes will be bind here. |
|||
@FXML |
|||
private Button multiplyButton, addButton, DetAButton, DetBButton, substractButton, transposeButton; |
|||
@FXML |
|||
private Text errorText, outputText; |
|||
@FXML |
|||
private TextArea matrixATextArea, matrixBTextArea; |
|||
|
|||
private MatrixCalcMath math = new MatrixCalcMath(); |
|||
private MatrixCalcIOUtils util = new MatrixCalcIOUtils(); |
|||
|
|||
/** |
|||
* Konstructor is called before initialize() |
|||
*/ |
|||
public MatrixCalcController() { |
|||
// Setup of some Fields could be defined here. |
|||
} |
|||
|
|||
/** |
|||
* Initializes the controller class. This method is automatically called after |
|||
* the fxml file has been loaded. |
|||
*/ |
|||
@FXML |
|||
public void initialize() { |
|||
/** |
|||
* Convert Strings to matricies, multiply them and output the result. |
|||
*/ |
|||
multiplyButton.setOnMouseClicked((event) -> { |
|||
String stringMatrixA = matrixATextArea.getText(); |
|||
String stringMatrixB = matrixBTextArea.getText(); |
|||
String[] stringMatrix = { stringMatrixA, stringMatrixB }; |
|||
|
|||
checkInputAndDisplayIfInputIsNotValid(stringMatrix, 2); |
|||
|
|||
ArrayList<double[][]> matricies = new ArrayList<double[][]>(); |
|||
matricies.add(util.stringToMatrix(stringMatrixA)); |
|||
matricies.add(util.stringToMatrix(stringMatrixB)); |
|||
|
|||
invokeOperation(matricies, MULTIPLICATION_STRING); |
|||
}); |
|||
|
|||
/** |
|||
* Convert a String to a matrix, transpose it and output the result. |
|||
*/ |
|||
transposeButton.setOnMouseClicked((event) -> { |
|||
String stringMatrixA = matrixATextArea.getText(); |
|||
String[] stringMatrix = { stringMatrixA, "" }; |
|||
|
|||
checkInputAndDisplayIfInputIsNotValid(stringMatrix, 1); |
|||
|
|||
ArrayList<double[][]> matricies = new ArrayList<double[][]>(); |
|||
matricies.add(util.stringToMatrix(stringMatrixA)); |
|||
|
|||
invokeOperation(matricies, TRANPOSE_STRING); |
|||
}); |
|||
|
|||
/** |
|||
* Convert Strings to matricies, add them and output the result. |
|||
*/ |
|||
addButton.setOnMouseClicked((event) -> { |
|||
String stringMatrixA = matrixATextArea.getText(); |
|||
String stringMatrixB = matrixBTextArea.getText(); |
|||
String[] stringMatrix = { stringMatrixA, stringMatrixB }; |
|||
|
|||
checkInputAndDisplayIfInputIsNotValid(stringMatrix, 2); |
|||
|
|||
ArrayList<double[][]> matricies = new ArrayList<double[][]>(); |
|||
matricies.add(util.stringToMatrix(stringMatrixA)); |
|||
matricies.add(util.stringToMatrix(stringMatrixB)); |
|||
|
|||
invokeOperation(matricies, ADDITION_STRING); |
|||
}); |
|||
|
|||
/** |
|||
* Convert Strings to matricies, substract them and output the result. |
|||
*/ |
|||
substractButton.setOnMouseClicked((event) -> { |
|||
String stringMatrixA = matrixATextArea.getText(); |
|||
String stringMatrixB = matrixBTextArea.getText(); |
|||
String[] stringMatrix = { stringMatrixA, stringMatrixB }; |
|||
|
|||
checkInputAndDisplayIfInputIsNotValid(stringMatrix, 2); |
|||
|
|||
ArrayList<double[][]> matricies = new ArrayList<double[][]>(); |
|||
matricies.add(util.stringToMatrix(stringMatrixA)); |
|||
matricies.add(util.stringToMatrix(stringMatrixB)); |
|||
|
|||
invokeOperation(matricies, SUBSTRACTION_STRING); |
|||
}); |
|||
|
|||
/** |
|||
* Convert the String of the left inputField to a matrix, calculate the Determinate and output it. |
|||
*/ |
|||
DetAButton.setOnMouseClicked((event) -> { |
|||
String stringMatrixA = matrixATextArea.getText(); |
|||
String[] stringMatrix = { stringMatrixA, "" }; |
|||
|
|||
checkInputAndDisplayIfInputIsNotValid(stringMatrix, 1); |
|||
|
|||
ArrayList<double[][]> matricies = new ArrayList<double[][]>(); |
|||
matricies.add(util.stringToMatrix(stringMatrixA)); |
|||
|
|||
invokeOperation(matricies, CALCDETERMINAT_STRING); |
|||
}); |
|||
|
|||
/** |
|||
* Convert the String of the right inputField to a matrix, calculate the Determinate and output it. |
|||
*/ |
|||
DetBButton.setOnMouseClicked((event) -> { |
|||
String stringMatrixB = matrixBTextArea.getText(); |
|||
String[] stringMatrix = { "", stringMatrixB }; |
|||
|
|||
checkInputAndDisplayIfInputIsNotValid(stringMatrix, 1); |
|||
|
|||
ArrayList<double[][]> matricies = new ArrayList<double[][]>(); |
|||
matricies.add(util.stringToMatrix(stringMatrixB)); |
|||
|
|||
invokeOperation(matricies, CALCDETERMINAT_STRING); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Invokes the needed operations form the MatrixCalcMath class |
|||
* @param matricies Contains both Matricies or onely one Matrix |
|||
* @param operation One of the global Constats to select wich Operation is needed. |
|||
*/ |
|||
private void invokeOperation(ArrayList<double[][]> matricies, String operation) { |
|||
if (matricies.size() == 2) { |
|||
if (operation.equals(MULTIPLICATION_STRING)) { |
|||
try { |
|||
double[][] result = math.matrixMultiplication(matricies.get(0), matricies.get(1)); |
|||
|
|||
String DisplayableString = util.outputMatrixToOutputText(result); |
|||
|
|||
outputText.setText(DisplayableString); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} catch (IllegalArgumentException e) { |
|||
|
|||
outputText.setText(e.getMessage()); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} |
|||
} else if (operation.equals(ADDITION_STRING)) { |
|||
try { |
|||
double[][] result = math.matrixAddition(matricies.get(0), matricies.get(1)); |
|||
|
|||
String DisplayableString = util.outputMatrixToOutputText(result); |
|||
|
|||
outputText.setText(DisplayableString); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} catch (IllegalArgumentException e) { |
|||
|
|||
outputText.setText(e.getMessage()); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} |
|||
} else if (operation.equals(SUBSTRACTION_STRING)) { |
|||
try { |
|||
double[][] result = math.matrixSubstraction(matricies.get(0), matricies.get(1)); |
|||
|
|||
String DisplayableString = util.outputMatrixToOutputText(result); |
|||
|
|||
outputText.setText(DisplayableString); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} catch (IllegalArgumentException e) { |
|||
|
|||
outputText.setText(e.getMessage()); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} |
|||
} |
|||
}else if (matricies.size() == 1) { |
|||
if (operation.equals(TRANPOSE_STRING)) { |
|||
try { |
|||
double[][] result = math.matrixTransponation(matricies.get(0)); |
|||
|
|||
String DisplayableString = util.outputMatrixToOutputText(result); |
|||
|
|||
outputText.setText(DisplayableString); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} catch (IllegalArgumentException e) { |
|||
|
|||
outputText.setText(e.getMessage()); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} |
|||
} |
|||
if (operation.equals(CALCDETERMINAT_STRING)) { |
|||
try { |
|||
double result = math.calcDeterminat(matricies.get(0)); |
|||
|
|||
String DisplayableString = Double.toString(result); |
|||
|
|||
outputText.setText(DisplayableString); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} catch (IllegalArgumentException e) { |
|||
|
|||
outputText.setText(e.getMessage()); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} catch (Exception e){ |
|||
|
|||
outputText.setText(e.getMessage()); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Checks the Input and Displays it if the Input is valid. |
|||
* |
|||
* @param stringMatrix Contains both input matrices if |
|||
* numberOfMarriciesToMatch is 2. If the number |
|||
* is 1 than one of them has to be a empty String |
|||
* @param numberOfMatricesToMatch If the number is 1 onely one Marix will be |
|||
* verifyed and the other one needs to be an empty |
|||
* String in the stringMatrix |
|||
*/ |
|||
private void checkInputAndDisplayIfInputIsNotValid(String[] stringMatrix, int numberOfMatricesToMatch) { |
|||
if (numberOfMatricesToMatch == 1 && !stringMatrix[0].equals("")) { |
|||
try { |
|||
util.checkInput(stringMatrix[0]); |
|||
} catch (Exception e) { |
|||
outputText.setText(e.getMessage() + "A"); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} |
|||
} else if (numberOfMatricesToMatch == 1 && !stringMatrix[1].equals("")) { |
|||
try { |
|||
util.checkInput(stringMatrix[1]); |
|||
} catch (Exception e) { |
|||
outputText.setText(e.getMessage() + "B"); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} |
|||
} else if (numberOfMatricesToMatch == 2 && !stringMatrix[0].equals("") && !stringMatrix[1].equals("")) { |
|||
try { |
|||
util.checkInput(stringMatrix[0]); |
|||
} catch (Exception e) { |
|||
outputText.setText(e.getMessage() + "A"); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} |
|||
|
|||
try { |
|||
util.checkInput(stringMatrix[1]); |
|||
} catch (Exception e) { |
|||
outputText.setText(e.getMessage() + "B"); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} |
|||
} else if (stringMatrix[0].equals("")) { |
|||
|
|||
outputText.setText("Pease insert MatrixA"); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
|
|||
} else if (stringMatrix[1].equals("")) { |
|||
|
|||
outputText.setText("Pease insert MatrixB"); |
|||
outputText.setTextAlignment(TextAlignment.CENTER); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,97 @@ |
|||
package com.ugsbo.matrixcalc; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.regex.Matcher; |
|||
import java.util.regex.Pattern; |
|||
|
|||
public class MatrixCalcIOUtils { |
|||
/** |
|||
* Prints a given 2D-Array to the output Textfield. |
|||
* |
|||
* @param output2DArray The Array that gets Displayed |
|||
*/ |
|||
protected String outputMatrixToOutputText(double[][] output2DArray) { |
|||
// convert array to String |
|||
String DisplayableString = convertsArrayToStringInOrderToDisplayIt(output2DArray); |
|||
// Display output |
|||
return DisplayableString; |
|||
} |
|||
|
|||
/** |
|||
* Converts 2D-Array to String in order to Display it. |
|||
* |
|||
* @param array2D The array wich will be converted to an Displayable String |
|||
* @return The Displayable String |
|||
*/ |
|||
protected String convertsArrayToStringInOrderToDisplayIt(double[][] array2D) { |
|||
String displayableString = ""; |
|||
for (int i = 0; i < array2D.length; i++) { |
|||
for (int j = 0; j < array2D[0].length; j++) { |
|||
displayableString += array2D[i][j] + " "; |
|||
} |
|||
displayableString += "\n\n"; |
|||
} |
|||
return displayableString; |
|||
} |
|||
|
|||
/** |
|||
* Checks if the Input is Valid, with Regex. Returns true if the Matrix can be |
|||
* matched by the regular Expression. |
|||
* |
|||
* @param matrix It is the InputMatrix |
|||
* @return True if the Matrix is valid Input. |
|||
*/ |
|||
protected void checkInput(String matrix) throws IllegalArgumentException { |
|||
if (matrix.length() == 0) { |
|||
throw new IllegalArgumentException("Please insert a Matrix"); |
|||
} |
|||
|
|||
// Matches digits witch following spaces 1 to 3 times |
|||
String row1 = "(\\d*\\u0020*){1,3}"; |
|||
// Matches newlineCurrierReturn followed by digits witch following spaces 1 to |
|||
// 3 times |
|||
String row2 = "(\\n){0,3}(\\d*\\u0020*){0,3}"; |
|||
String row3 = "(\\n){0,3}(\\d*\\u0020*){0,3}"; |
|||
|
|||
// TODO for verion 2 get the input check more stricktly missing matrix slots are allowed. |
|||
|
|||
Pattern p = Pattern.compile(row1 + row2 + row3); |
|||
Matcher m = p.matcher(matrix); |
|||
|
|||
if(!m.matches()){ |
|||
throw new IllegalArgumentException("A Matrix is not in the right format, Matrix "); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Converts a String form the Inputfield to an 2D-Array aka Matrix. |
|||
* |
|||
* @param stringMatrix The String form the Inputfield |
|||
* @return Matrix as a 2D-Array |
|||
*/ |
|||
public double[][] stringToMatrix(String stringMatrix) { |
|||
|
|||
ArrayList<String[]> singleNumbersArr = new ArrayList<String[]>(); |
|||
|
|||
// Splitting the strings into their rows |
|||
String[] singleNumbers = null; |
|||
String[] rows = stringMatrix.split("\n"); |
|||
for (int i = 0; i < rows.length; i++) { |
|||
// Splitting rows into their Numbers |
|||
singleNumbers = rows[i].split("\\s"); |
|||
singleNumbersArr.add(singleNumbers); |
|||
} |
|||
|
|||
int rowlength = singleNumbersArr.get(0).length; |
|||
int columCount = singleNumbersArr.size(); |
|||
double[][] matrix = new double[columCount][rowlength]; |
|||
|
|||
for (int columIndex = 0; columIndex < columCount; columIndex++) { |
|||
for (int rowIndex = 0; rowIndex < singleNumbers.length; rowIndex++) { |
|||
matrix[columIndex][rowIndex] = Double.parseDouble(singleNumbersArr.get(columIndex)[rowIndex]); |
|||
} |
|||
} |
|||
return matrix; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,228 @@ |
|||
package com.ugsbo.matrixcalc; |
|||
|
|||
/** |
|||
* Contains all basic matrix math calculations. |
|||
*/ |
|||
public class MatrixCalcMath { |
|||
|
|||
/** |
|||
* Mutliplys matrixA and matrixB. |
|||
* |
|||
* @param matrixA The Inputmatrix A (right TextArea in the GUI) |
|||
* @param matrixB The Inputmatrix B (left TextArea in the GUI) |
|||
* @return The Matrixproduct of the matricies A and B |
|||
*/ |
|||
public double[][] matrixMultiplication(double[][] matrixA, double[][] matrixB) { |
|||
if (checkIfMatriciesAreLinked(matrixA, matrixB)) { |
|||
int rowOfResultMatrix = matrixA.length; |
|||
int columOfResultMatrix = matrixB[0].length; |
|||
int ColumsOfMatA = matrixA[0].length; |
|||
double[][] result = new double[rowOfResultMatrix][columOfResultMatrix]; |
|||
|
|||
for (int rowResult = 0; rowResult < rowOfResultMatrix; rowResult++) { |
|||
for (int columResult = 0; columResult < columOfResultMatrix; columResult++) { |
|||
for (int columOfA = 0; columOfA < ColumsOfMatA; columOfA++) { |
|||
result[rowResult][columResult] += matrixA[rowResult][columOfA] * matrixB[columOfA][columResult]; |
|||
} |
|||
} |
|||
} |
|||
return result; |
|||
} else { |
|||
throw new IllegalArgumentException("Matricies must be linked"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* checks if matrixA and matrixB are linked to know if it is possible to |
|||
* multiply them. If they are linked it is possible. |
|||
* |
|||
* @param matrixA The Inputmatrix A (right TextArea in the GUI) |
|||
* @param matrixB The Inputmatrix B (left TextArea in the GUI) |
|||
* @return true if you can Muliply A with B false if not. |
|||
*/ |
|||
public boolean checkIfMatriciesAreLinked(double[][] matrixA, double[][] matrixB) { |
|||
if (matrixA == null) { |
|||
return false; |
|||
} |
|||
if (matrixA.length == 0) { |
|||
return false; |
|||
} |
|||
if (matrixA[0].length == matrixB.length) { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
/** |
|||
* Adds two matroices A and B. Adding matrix A to matrix B is the same as adding |
|||
* B to A. |
|||
* |
|||
* @param matrixA The Inputmatrix A (right TextArea in the GUI) |
|||
* @param matrixB The Inputmatrix B (left TextArea in the GUI) |
|||
* @return The Matrixsum of matrix A and matrix B |
|||
*/ |
|||
public double[][] matrixAddition(double[][] matrixA, double[][] matrixB) { |
|||
if (checkIfMatriciesAreTheSameDimension(matrixA, matrixB)) { |
|||
double[][] result = new double[matrixA.length][matrixA[0].length]; |
|||
for (int rows = 0; rows < matrixA.length; rows++) { |
|||
for (int colums = 0; colums < matrixA[0].length; colums++) { |
|||
result[rows][colums] = matrixA[rows][colums] + matrixB[rows][colums]; |
|||
} |
|||
} |
|||
return result; |
|||
} else { |
|||
throw new IllegalArgumentException("Matricies need to have the same Dimensions"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* In order to adding two Matricies they must have the same Dimensions. This |
|||
* Methode checks if this is the case. |
|||
* |
|||
* @param matrixA The Inputmatrix A (right TextArea in the GUI) |
|||
* @param matrixB The Inputmatrix B (left TextArea in the GUI) |
|||
* @return true if the Dimensions of Matrix A equals the Dimensions Matrix B |
|||
*/ |
|||
public boolean checkIfMatriciesAreTheSameDimension(double[][] matrixA, double[][] matrixB) { |
|||
if (matrixA == null || matrixA.length == 0) { |
|||
return false; |
|||
} |
|||
if (matrixA[0] == null) { |
|||
return false; |
|||
} |
|||
if (matrixA.length == matrixB.length && matrixA[0].length == matrixB[0].length) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* Substracts matrix A by the matrix B. Substaction for Matrices is just the |
|||
* substraction of each component with thier coorsponding component. |
|||
* |
|||
* @param matrixA The Inputmatrix A (right TextArea in the GUI) |
|||
* @param matrixB The Inputmatrix B (left TextArea in the GUI |
|||
* @return matrix A substracted by matrix B |
|||
*/ |
|||
public double[][] matrixSubstraction(double[][] matrixA, double[][] matrixB) { |
|||
if (checkIfMatriciesAreTheSameDimension(matrixA, matrixB)) { |
|||
double[][] result = new double[matrixA.length][matrixA[0].length]; |
|||
for (int rows = 0; rows < matrixA.length; rows++) { |
|||
for (int colums = 0; colums < matrixA[0].length; colums++) { |
|||
result[rows][colums] = matrixA[rows][colums] - matrixB[rows][colums]; |
|||
} |
|||
} |
|||
return result; |
|||
} else { |
|||
throw new IllegalArgumentException("Matricies need to have the same Dimensions"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Transposes the Input Matrix. Swaps rows with colums. |
|||
* |
|||
* @param matrixA The Inputmatrix A wich will be Transposed |
|||
* @return The Transposed matrix of matrix A |
|||
*/ |
|||
public double[][] matrixTransponation(double[][] matrixA) { |
|||
if (matrixA == null) { |
|||
throw new IllegalArgumentException("Matricies need to have the same Dimensions"); |
|||
} |
|||
if (matrixA.length == 0) { |
|||
throw new IllegalArgumentException("Matricies need to have the same Dimensions"); |
|||
} |
|||
if (matrixA[0] == null) { |
|||
throw new IllegalArgumentException("Matricies need to have the same Dimensions"); |
|||
} |
|||
int columCountResult = matrixA.length; |
|||
int rowCountResult = matrixA[0].length; |
|||
double[][] result = new double[rowCountResult][columCountResult]; |
|||
for (int row = 0; row < rowCountResult; row++) { |
|||
for (int colum = 0; colum < columCountResult; colum++) { |
|||
result[row][colum] = matrixA[colum][row]; |
|||
} |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* Calculates the Determinant of a Matrix. |
|||
* |
|||
* @param matrixA The Inputmatrix |
|||
* @return The Determinant of the Matrix A |
|||
*/ |
|||
public double calcDeterminat(double[][] matrixA) throws IllegalArgumentException{ |
|||
// checking if a Determinant can be calculated. |
|||
double result = 0.0; |
|||
if (checkIfMatrixIsQuadradtic(matrixA)) { |
|||
if (getMatrixRowCount(matrixA) == 2) { |
|||
result = calc2by2Determinant(matrixA); |
|||
} else if (getMatrixRowCount(matrixA) == 3) { |
|||
result = calc3by3Determinant(matrixA); |
|||
|
|||
} else { |
|||
throw new IllegalArgumentException("Matrix is not 2 by 2 or 3 by 3"); |
|||
} |
|||
|
|||
} else { |
|||
throw new IllegalArgumentException("Matrix must be Quadratic"); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* Calculates the Determinat of an three by three Matrix. |
|||
* |
|||
* @param matrixA The Inputmatrix form wich the Determinat will be calculated |
|||
* @return the Determinant of the Matrix |
|||
*/ |
|||
private double calc3by3Determinant(double[][] matrixA) { |
|||
double result = matrixA[0][0] * matrixA[1][1] * matrixA[2][2] + matrixA[0][1] * matrixA[1][2] * matrixA[2][0] |
|||
+ matrixA[0][2] * matrixA[1][0] * matrixA[2][1] - matrixA[0][0] * matrixA[1][2] * matrixA[2][1] |
|||
- matrixA[0][1] * matrixA[1][0] * matrixA[2][2] - matrixA[0][2] * matrixA[1][1] * matrixA[2][0]; |
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* Calculates the Determinat of an two by two Matrix. |
|||
* |
|||
* @param matrixA The Inputmatrix form wich the Determinat will be calculated |
|||
* @return the Determinant of the Matrix |
|||
*/ |
|||
private double calc2by2Determinant(double[][] matrixA) { |
|||
double result = matrixA[0][0] * matrixA[1][1] - matrixA[0][1] * matrixA[1][0]; |
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* Returns the Number of rows of a Matrix. |
|||
* |
|||
* @param matrixA the Inputmatrix form wich the rows will be counted |
|||
* @return Number of rows |
|||
*/ |
|||
private int getMatrixRowCount(double[][] matrixA) { |
|||
return matrixA.length; |
|||
} |
|||
|
|||
/** |
|||
* Checks if the rows and colums of an Matrix are equal. If they are equal the |
|||
* Matrix is Quadratic and the function will return true. |
|||
* |
|||
* @param matrixA the Inputmatrix for wich the rows and colums will be compared |
|||
* @return isQuadratic |
|||
*/ |
|||
private boolean checkIfMatrixIsQuadradtic(double[][] matrixA) { |
|||
if (matrixA == null) { |
|||
return false; |
|||
} |
|||
if (matrixA[0] == null) { |
|||
return false; |
|||
} |
|||
if (matrixA.length == matrixA[0].length) { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
} |
@ -1,8 +0,0 @@ |
|||
module UGSBO { |
|||
requires javafx.controls; |
|||
requires javafx.fxml; |
|||
|
|||
opens com.ugsbo.gui to javafx.fxml; |
|||
|
|||
exports com.ugsbo.gui; |
|||
} |
@ -0,0 +1,15 @@ |
|||
package ugsbo.com.buchhaltung; |
|||
|
|||
public class Auswertung { |
|||
|
|||
public static void main(String[] args) { |
|||
// TODO Auto-generated method stub |
|||
Blockchain Work = new Blockchain(); |
|||
Work.add(50); |
|||
Work.add(-20); |
|||
|
|||
System.out.println(Work.kontostand()); |
|||
System.out.print(Work.toString()); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
package ugsbo.com.buchhaltung; |
|||
|
|||
import java.security.MessageDigest; |
|||
|
|||
public class Block { |
|||
|
|||
|
|||
int data; |
|||
int kontostand; |
|||
Block vorher; |
|||
|
|||
String ownHash; |
|||
String previousHash; |
|||
|
|||
|
|||
//erste Block |
|||
public Block(int data) { |
|||
this.data = data; |
|||
ownHash = createNewHash(Integer.toString(data)); |
|||
|
|||
kontostand = this.data; |
|||
|
|||
this.vorher = null; |
|||
this.previousHash = null; |
|||
} |
|||
|
|||
//Alle anderen Blöcke |
|||
public Block(int data, Block vorher, String previousHash, int konto) { |
|||
this.data = data; |
|||
ownHash = createNewHash(Integer.toString(data)+previousHash); |
|||
|
|||
kontostand = konto + this.data; |
|||
|
|||
this.vorher = vorher; |
|||
this.previousHash = previousHash; |
|||
} |
|||
|
|||
private String createNewHash(String input) { |
|||
try { |
|||
MessageDigest digest = MessageDigest.getInstance("SHA-256"); |
|||
//Applies sha256 to our input, |
|||
byte[] hash = digest.digest(input.getBytes("UTF-8")); |
|||
StringBuffer hexString = new StringBuffer(); // This will contain hash as hexidecimal |
|||
for (int i = 0; i < hash.length; i++) { |
|||
String hex = Integer.toHexString(0xff & hash[i]); |
|||
if(hex.length() == 1) hexString.append('0'); |
|||
hexString.append(hex); |
|||
} |
|||
return hexString.toString(); |
|||
} |
|||
catch(Exception e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
|
|||
public int getKontostand() { |
|||
return kontostand; |
|||
} |
|||
|
|||
public Block getVorher() { |
|||
return vorher; |
|||
} |
|||
|
|||
public String getHash() { |
|||
return ownHash; |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package ugsbo.com.buchhaltung; |
|||
|
|||
import com.google.gson.*; |
|||
|
|||
public class Blockchain { |
|||
|
|||
Block Workingobjekt; |
|||
|
|||
|
|||
public Blockchain() { |
|||
Workingobjekt = new Block(0); |
|||
} |
|||
|
|||
|
|||
public void add(int eingabe) { |
|||
Block newWorkingobjekt = new Block(eingabe, Workingobjekt, Workingobjekt.getHash(), Workingobjekt.getKontostand()); |
|||
|
|||
Workingobjekt = newWorkingobjekt; |
|||
} |
|||
|
|||
|
|||
public int kontostand() { |
|||
return Workingobjekt.getKontostand(); |
|||
} |
|||
|
|||
public String toString() { |
|||
String JSON = new GsonBuilder().setPrettyPrinting().create().toJson(Workingobjekt); |
|||
return JSON; |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package ugsbo.com.notenSpeicher; |
|||
|
|||
public class Auswertung { |
|||
|
|||
public static void main(String[] args) { |
|||
NotenKette Work = new NotenKette("Prog 1", 1); |
|||
Work.add("Prog 2", 2); |
|||
Work.add("Wi", 3); |
|||
|
|||
System.out.println(Work.durchschnitt() + "\n"); |
|||
|
|||
System.out.print(Work.toString()); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,77 @@ |
|||
package ugsbo.com.notenSpeicher; |
|||
|
|||
import java.security.MessageDigest; |
|||
|
|||
public class Noten { |
|||
|
|||
|
|||
String Fach; |
|||
int Note; |
|||
double durchschnitt; |
|||
Noten vorher; |
|||
|
|||
String ownHash; |
|||
String previousHash; |
|||
|
|||
public Noten(String eingabeFach, int eingabeNote) { |
|||
Fach = eingabeFach; |
|||
Note = eingabeNote; |
|||
durchschnitt = eingabeNote; |
|||
|
|||
vorher = null; |
|||
previousHash = null; |
|||
|
|||
ownHash = createNewHash(eingabeFach); |
|||
} |
|||
|
|||
public Noten(String eingabeFach, int eingabeNote, String previousHash, double durchschnitt, Noten vorher) { |
|||
Fach = eingabeFach; |
|||
Note = eingabeNote; |
|||
ownHash = createNewHash(eingabeFach+previousHash); |
|||
|
|||
this.durchschnitt = (durchschnitt+eingabeNote)/2; |
|||
|
|||
this.vorher = vorher; |
|||
this.previousHash = previousHash; |
|||
} |
|||
|
|||
private String createNewHash(String input) { |
|||
try { |
|||
MessageDigest digest = MessageDigest.getInstance("SHA-256"); |
|||
//Applies sha256 to our input, |
|||
byte[] hash = digest.digest(input.getBytes("UTF-8")); |
|||
StringBuffer hexString = new StringBuffer(); // This will contain hash as hexidecimal |
|||
for (int i = 0; i < hash.length; i++) { |
|||
String hex = Integer.toHexString(0xff & hash[i]); |
|||
if(hex.length() == 1) hexString.append('0'); |
|||
hexString.append(hex); |
|||
} |
|||
return hexString.toString(); |
|||
} |
|||
catch(Exception e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
public String getFach() { |
|||
return Fach; |
|||
} |
|||
|
|||
public int getNote() { |
|||
return Note; |
|||
} |
|||
|
|||
public double getDurchschnitt() { |
|||
return durchschnitt; |
|||
} |
|||
|
|||
public Noten getVorher() { |
|||
return vorher; |
|||
} |
|||
|
|||
public String getOwnHash() { |
|||
return ownHash; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,38 @@ |
|||
package ugsbo.com.notenSpeicher; |
|||
|
|||
public class NotenKette { |
|||
|
|||
Noten Workingobjekt; |
|||
|
|||
public NotenKette(String eingabeFach, int eingabeNote) { |
|||
Workingobjekt = new Noten(eingabeFach, eingabeNote); |
|||
} |
|||
|
|||
public double durchschnitt() { |
|||
return Workingobjekt.getDurchschnitt(); |
|||
} |
|||
|
|||
public void add(String eingabeFach, int eingabeNote) { |
|||
if (eingabeNote == 0) return; |
|||
|
|||
Noten newWorkingObjekt = new Noten(eingabeFach,eingabeNote, Workingobjekt.previousHash, Workingobjekt.durchschnitt, Workingobjekt); |
|||
Workingobjekt = newWorkingObjekt; |
|||
} |
|||
|
|||
public String toString() { |
|||
String erg = ""; |
|||
Noten temp = Workingobjekt; |
|||
|
|||
while (true) { |
|||
erg += temp.getFach() + "\t"+ temp.getNote() +"\n"; |
|||
|
|||
temp = temp.getVorher(); |
|||
|
|||
if (temp == null) { |
|||
return erg; |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,41 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
|
|||
<?import javafx.geometry.*?> |
|||
<?import javafx.scene.paint.*?> |
|||
<?import javafx.scene.control.*?> |
|||
<?import javafx.scene.text.*?> |
|||
<?import java.lang.*?> |
|||
<?import javafx.scene.layout.*?> |
|||
|
|||
|
|||
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="400.0" minWidth="600.0" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ugsbo.gui.BasicGuiController"> |
|||
<children> |
|||
<AnchorPane maxHeight="50.0" minHeight="50.0" minWidth="-Infinity" prefHeight="50.0" prefWidth="600.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> |
|||
<children> |
|||
<Label text="UGSBO" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="10.0" /> |
|||
<TextField layoutX="415.0" layoutY="13.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="13.0" /> |
|||
</children> |
|||
</AnchorPane> |
|||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="140.0" minWidth="-Infinity" prefHeight="350.0" prefWidth="150.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="50.0"> |
|||
<children> |
|||
<Label layoutX="43.0" layoutY="14.0" text="Team O.o" AnchorPane.leftAnchor="43.0" AnchorPane.rightAnchor="43.0" AnchorPane.topAnchor="10.0" /> |
|||
<Label layoutX="22.0" layoutY="50.0" text="Christian Baltzer" AnchorPane.topAnchor="40.0" /> |
|||
<Label layoutX="14.0" layoutY="71.0" text="Carolin Brückmann" AnchorPane.topAnchor="71.0" /> |
|||
<Label layoutX="19.0" layoutY="109.0" text="Jacqueline Heinze" AnchorPane.topAnchor="100.0" /> |
|||
<Label layoutX="22.0" layoutY="130.0" text="Lukas Reichwein" AnchorPane.topAnchor="130.0" /> |
|||
</children> |
|||
</AnchorPane> |
|||
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="150.0" AnchorPane.topAnchor="50.0"> |
|||
<children> |
|||
<Button fx:id="matrixCalc" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="260.0" text="Matrix Calculator" textAlignment="CENTER" AnchorPane.leftAnchor="19.0" AnchorPane.rightAnchor="19.0" AnchorPane.topAnchor="15.0" /> |
|||
<Button fx:id="app2" maxHeight="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="260.0" text="App2" textAlignment="CENTER" AnchorPane.leftAnchor="19.0" AnchorPane.rightAnchor="19.0" AnchorPane.topAnchor="60.0" /> |
|||
<Button fx:id="app3" maxHeight="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="260.0" text="App3" textAlignment="CENTER" AnchorPane.leftAnchor="19.0" AnchorPane.rightAnchor="19.0" AnchorPane.topAnchor="105.0" /> |
|||
<Button fx:id="app4" maxHeight="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="260.0" text="App4" textAlignment="CENTER" AnchorPane.leftAnchor="19.0" AnchorPane.rightAnchor="19.0" AnchorPane.topAnchor="150.0" /> |
|||
</children> |
|||
<opaqueInsets> |
|||
<Insets /> |
|||
</opaqueInsets> |
|||
</AnchorPane> |
|||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="200.0" prefWidth="150.0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="50.0" /> |
|||
</children> |
|||
</AnchorPane> |
@ -0,0 +1,35 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
|
|||
<?import javafx.scene.control.Button?> |
|||
<?import javafx.scene.control.Label?> |
|||
<?import javafx.scene.control.Menu?> |
|||
<?import javafx.scene.control.MenuBar?> |
|||
<?import javafx.scene.control.TextField?> |
|||
<?import javafx.scene.layout.AnchorPane?> |
|||
<?import javafx.scene.layout.VBox?> |
|||
|
|||
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ugsbo.gui.Vokabelkartenschreiber"> |
|||
<children> |
|||
<MenuBar VBox.vgrow="NEVER"> |
|||
<menus> |
|||
<Menu mnemonicParsing="false" text="File"> |
|||
<graphic> |
|||
<Button mnemonicParsing="false" text="zurück" /> |
|||
</graphic> |
|||
</Menu> |
|||
</menus> |
|||
</MenuBar> |
|||
<AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS"> |
|||
<children> |
|||
<Label layoutX="14.0" layoutY="14.0" prefHeight="54.0" prefWidth="597.0" text="Willkommen! Bitte trage deine Karten in der unten gezeigte Form ein. Gibt es keine zweite Antwort, so lassen Sie das Feld frei. " /> |
|||
<TextField fx:id="Text_Name" layoutX="14.0" layoutY="84.0" prefHeight="27.0" prefWidth="597.0" promptText="Name" /> |
|||
<TextField fx:id="Text_Frage" layoutX="14.0" layoutY="123.0" prefHeight="27.0" prefWidth="597.0" promptText="Frage" /> |
|||
<TextField fx:id="Text_Antwort1" layoutX="14.0" layoutY="164.0" prefHeight="27.0" prefWidth="597.0" promptText="Antwort 1" /> |
|||
<TextField fx:id="Text_Antwort2" layoutX="14.0" layoutY="200.0" prefHeight="27.0" prefWidth="597.0" promptText="Antwort 2" /> |
|||
<TextField fx:id="Text_Antwort3" layoutX="14.0" layoutY="236.0" prefHeight="27.0" prefWidth="597.0" promptText="Antwort 3" /> |
|||
<TextField fx:id="Text_Antwort4" layoutX="14.0" layoutY="275.0" prefHeight="27.0" prefWidth="597.0" promptText="Antwort 4" /> |
|||
<Button fx:id="button_absenden" layoutX="277.0" layoutY="319.0" mnemonicParsing="false" onAction="#button_absenden_pressed" text="absenden" /> |
|||
</children> |
|||
</AnchorPane> |
|||
</children> |
|||
</VBox> |
@ -0,0 +1,37 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
|
|||
<?import java.lang.*?> |
|||
<?import javafx.scene.control.*?> |
|||
<?import javafx.scene.layout.*?> |
|||
<?import javafx.scene.text.*?> |
|||
<?import javafx.scene.control.Button?> |
|||
<?import javafx.scene.control.TextArea?> |
|||
<?import javafx.scene.layout.AnchorPane?> |
|||
<?import javafx.scene.text.Text?> |
|||
|
|||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ugsbo.matrixcalc.MatrixCalcController"> |
|||
<children> |
|||
<AnchorPane prefHeight="200.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0"> |
|||
<children> |
|||
<TextArea fx:id="matrixATextArea" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" /> |
|||
</children> |
|||
</AnchorPane> |
|||
<AnchorPane layoutX="200.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="200.0" AnchorPane.leftAnchor="200.0" AnchorPane.rightAnchor="200.0" AnchorPane.topAnchor="0.0"> |
|||
<children> |
|||
<Button fx:id="multiplyButton" layoutX="14.0" layoutY="27.0" mnemonicParsing="false" text="multiply" AnchorPane.leftAnchor="15.0" AnchorPane.topAnchor="27.0" /> |
|||
<Button fx:id="addButton" layoutX="14.0" layoutY="62.0" mnemonicParsing="false" text="add" AnchorPane.leftAnchor="15.0" AnchorPane.topAnchor="67.0" /> |
|||
<Button fx:id="substractButton" layoutX="99.0" layoutY="62.0" mnemonicParsing="false" text="Substract" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="67.0" /> |
|||
<Button fx:id="transposeButton" layoutX="97.0" layoutY="27.0" mnemonicParsing="false" text="Transpose" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="27.0" /> |
|||
<Button fx:id="DetAButton" layoutX="14.0" layoutY="95.0" mnemonicParsing="false" text="DetA" AnchorPane.leftAnchor="15.0" AnchorPane.topAnchor="107.0" /> |
|||
<Button fx:id="DetBButton" layoutX="120.0" layoutY="107.0" mnemonicParsing="false" text="DetB" /> |
|||
<Text fx:id="errorText" layoutX="14.0" layoutY="113.0" strokeType="OUTSIDE" strokeWidth="0.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="100.0" /> |
|||
</children> |
|||
</AnchorPane> |
|||
<AnchorPane layoutX="400.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> |
|||
<children> |
|||
<TextArea fx:id="matrixBTextArea" layoutX="-15.0" layoutY="30.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" /> |
|||
</children> |
|||
</AnchorPane> |
|||
<Text fx:id="outputText" layoutX="14.0" layoutY="242.0" strokeType="OUTSIDE" strokeWidth="0.0" textAlignment="JUSTIFY" wrappingWidth="554.7294921875" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="210.0" /> |
|||
</children> |
|||
</AnchorPane> |
@ -0,0 +1,4 @@ |
|||
.button { |
|||
-fx-font-weight: bold; |
|||
font-weight: bold; |
|||
} |
@ -0,0 +1,63 @@ |
|||
package com.ugsbo.Buchhaltung; |
|||
|
|||
import static org.junit.Assert.*; |
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
import ugsbo.com.buchhaltung.Blockchain; |
|||
|
|||
public class Test_Blockchain { |
|||
|
|||
public Blockchain Workingobjekt; |
|||
|
|||
@Before |
|||
public void setUp() throws Exception { |
|||
Workingobjekt = new Blockchain(); |
|||
} |
|||
|
|||
@Test |
|||
public void hinzufügen() { |
|||
int eingabe = 500; |
|||
int ergebnis; |
|||
|
|||
Workingobjekt.add(eingabe); |
|||
ergebnis = Workingobjekt.kontostand(); |
|||
|
|||
assertEquals("eingabe und Ergebnis sind gleich", eingabe, ergebnis); |
|||
} |
|||
|
|||
@Test |
|||
public void hinzufügenNegativ() { |
|||
int eingabe = -500; |
|||
int ergebnis; |
|||
|
|||
Workingobjekt.add(eingabe); |
|||
ergebnis = Workingobjekt.kontostand(); |
|||
|
|||
assertEquals("eingabe und Ergebnis sind gleich", eingabe, ergebnis); |
|||
} |
|||
|
|||
@Test |
|||
public void hinzufügenIstNull() { |
|||
int eingabe = 0; |
|||
int ergebnis; |
|||
|
|||
Workingobjekt.add(eingabe); |
|||
ergebnis = Workingobjekt.kontostand(); |
|||
|
|||
assertEquals("eingabe und Ergebnis sind gleich", eingabe, ergebnis); |
|||
} |
|||
|
|||
@Test |
|||
public void hinzufügenMehrAlsEinmal() { |
|||
int eingabe = 100; |
|||
int erwartet = 300; |
|||
int ergebnis; |
|||
|
|||
Workingobjekt.add(eingabe); |
|||
Workingobjekt.add(eingabe); |
|||
Workingobjekt.add(eingabe); |
|||
ergebnis = Workingobjekt.kontostand(); |
|||
|
|||
assertEquals("eingabe und Ergebnis sind gleich", erwartet, ergebnis); |
|||
} |
|||
} |
@ -0,0 +1,66 @@ |
|||
/** |
|||
* |
|||
*/ |
|||
package com.ugsbo.Crypto; |
|||
|
|||
import com.ugsbo.Crypto.*; |
|||
import static org.junit.Assert.*; |
|||
import java.io.UnsupportedEncodingException; |
|||
import java.security.GeneralSecurityException; |
|||
import java.security.NoSuchAlgorithmException; |
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
|
|||
public class Crypt { |
|||
|
|||
|
|||
private Payload workingobjekt; |
|||
|
|||
@Before |
|||
public void setUp() throws Exception { |
|||
workingobjekt = new Payload(); |
|||
} |
|||
|
|||
@Test |
|||
public void offenIstAnders() { |
|||
|
|||
String eingabe = "TestText"; |
|||
String ergebnis; |
|||
String password = ""; |
|||
|
|||
try { |
|||
workingobjekt.setOffen(eingabe); |
|||
workingobjekt.setPassword(password); |
|||
workingobjekt.entschlüsseln(); |
|||
} catch (GeneralSecurityException e) { |
|||
e.printStackTrace(); |
|||
} catch (UnsupportedEncodingException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
ergebnis = workingobjekt.getVerschlüsselt(); |
|||
|
|||
assertNotEquals("unterschidliche Texte", eingabe, ergebnis); |
|||
} |
|||
|
|||
@Test |
|||
public void verUndEntschlüsseln() { |
|||
|
|||
String password = "Test"; |
|||
String eingabe = "TestText"; |
|||
String ergebnis; |
|||
|
|||
try { |
|||
workingobjekt.setOffen(eingabe); |
|||
workingobjekt.setPassword(password); |
|||
workingobjekt.verschlüsseln(); |
|||
workingobjekt.entschlüsseln(); |
|||
} catch (GeneralSecurityException | UnsupportedEncodingException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
ergebnis = workingobjekt.getOffen(); |
|||
|
|||
assertEquals("das entschlüsselte Test Wort", ergebnis, eingabe); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,62 @@ |
|||
package com.ugsbo.Crypto; |
|||
|
|||
import static org.junit.Assert.*; |
|||
import java.io.UnsupportedEncodingException; |
|||
import java.security.GeneralSecurityException; |
|||
import com.ugsbo.Crypto.*; |
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
|
|||
public class DeCrypt { |
|||
|
|||
private Payload workingobjekt; |
|||
|
|||
@Before |
|||
public void setUp() throws Exception { |
|||
workingobjekt = new Payload(); |
|||
} |
|||
|
|||
@Test |
|||
public void verschlüsseltIstAnders() { |
|||
|
|||
String eingabe = "TestText"; |
|||
String password = "Test"; |
|||
String ergebnis; |
|||
|
|||
try { |
|||
workingobjekt.setVerschlüsselt(eingabe); |
|||
workingobjekt.setPassword(password); |
|||
workingobjekt.entschlüsseln(); |
|||
} catch (GeneralSecurityException e) { |
|||
e.printStackTrace(); |
|||
} catch (UnsupportedEncodingException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
ergebnis = workingobjekt.getOffen(); |
|||
|
|||
assertNotEquals("unterschidliche Texte", eingabe, ergebnis); |
|||
} |
|||
|
|||
@Test |
|||
public void entUndVerschlüsseln() { |
|||
|
|||
String password = "Test"; |
|||
String eingabe = "TestText"; |
|||
String ergebnis; |
|||
|
|||
try { |
|||
workingobjekt.setOffen(eingabe); |
|||
workingobjekt.setPassword(password); |
|||
workingobjekt.verschlüsseln(); |
|||
workingobjekt.entschlüsseln(); |
|||
} catch (GeneralSecurityException | UnsupportedEncodingException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
ergebnis = workingobjekt.getOffen(); |
|||
|
|||
assertEquals("das entschlüsselte Test Wort", ergebnis, eingabe); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
/** |
|||
* |
|||
*/ |
|||
package com.ugsbo.FirewallOfDeath; |
|||
|
|||
import static org.junit.Assert.*; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
/** |
|||
* @author christian |
|||
* Tests für die Funktion FirewallOfDeath, welche sich schlecht testen lässt ._. |
|||
*/ |
|||
public class UselessTest { |
|||
|
|||
@Test |
|||
public void test() { |
|||
assertTrue(true); |
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
/** |
|||
* |
|||
*/ |
|||
package com.ugsbo.IsMyComputerOn; |
|||
|
|||
import static org.junit.Assert.*; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
/** |
|||
* @author christian |
|||
* Testen der Funktionen "IsMyComputerOn" |
|||
*/ |
|||
public class IstErAn { |
|||
|
|||
@Test |
|||
public void test() { |
|||
assertTrue("Funktion gibt false zurück? O.o",IsMyComputerOn_App.IstErAn()); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,62 @@ |
|||
package com.ugsbo.VokabelKartenSchreiber; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
|
|||
import com.ugsbo.VokableKartenSchreiber.Vokabelkarte; |
|||
|
|||
public class NichtLeeralsohinzufügenTest { |
|||
|
|||
private Vokabelkarte workingObjekt; |
|||
|
|||
|
|||
@Before |
|||
public void setup() { |
|||
workingObjekt = new Vokabelkarte(); |
|||
} |
|||
|
|||
@Test |
|||
public void NichtAlsLeeralsoHinzufügen_TestMitAllenParametern() { |
|||
Vokabelkarte WorkingObjekt = workingObjekt; |
|||
|
|||
String neuesWort = "prüfenTest"; |
|||
String wortfolgeBisher = "RückgabeTest"; |
|||
String separator = "ZwischenwertTest"; |
|||
String erwartet = "RückgabeTestprüfenTestZwischenwertTest"; |
|||
|
|||
String ergebnis = WorkingObjekt.NichtLeeralsohinzufügen(wortfolgeBisher,neuesWort,separator); |
|||
|
|||
assertEquals("Seperator angehängt + Neues Wort", erwartet, ergebnis); |
|||
} |
|||
|
|||
@Test |
|||
public void NichtAlsLeeralsoHinzufügen_neuesWortIstLeer() { |
|||
Vokabelkarte WorkingObjekt = workingObjekt; |
|||
|
|||
String neuesWort = ""; |
|||
String wortfolgeBisher = "RückgabeTest"; |
|||
String separator = "ZwischenwertTest"; |
|||
String erwartet = "RückgabeTest"; |
|||
|
|||
String ergebnis = WorkingObjekt.NichtLeeralsohinzufügen(wortfolgeBisher,neuesWort,separator); |
|||
|
|||
assertEquals("WortFolgebisher zurückgegeben", erwartet, ergebnis); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void NichtAlsLeeralsoHinzufügen_AllesLeer() { |
|||
Vokabelkarte WorkingObjekt = workingObjekt; |
|||
|
|||
String neuesWort = ""; |
|||
String wortfolgeBisher = ""; |
|||
String separator = ""; |
|||
String erwartet = ""; |
|||
|
|||
String ergebnis = WorkingObjekt.NichtLeeralsohinzufügen(wortfolgeBisher,neuesWort,separator); |
|||
|
|||
assertEquals("leer", erwartet, ergebnis); |
|||
} |
|||
} |
@ -0,0 +1,108 @@ |
|||
package com.ugsbo.VokabelKartenSchreiber; |
|||
|
|||
import static org.junit.Assert.*; |
|||
|
|||
import org.junit.*; |
|||
|
|||
import com.ugsbo.VokableKartenSchreiber.Vokabelkarte; |
|||
|
|||
public class makeStringTest { |
|||
|
|||
private Vokabelkarte workingObjekt; |
|||
|
|||
@Before |
|||
public void setup() { |
|||
workingObjekt = new Vokabelkarte(); |
|||
} |
|||
|
|||
@Test |
|||
public void makeString_ReturnsStringKorrekt() { |
|||
Vokabelkarte WorkingObjekt = workingObjekt; |
|||
|
|||
String name = "TestName"; |
|||
String frage = "TestFrage"; |
|||
String antwort1 = "TestAntwort"; |
|||
String antwort2 = "TestAntwort"; |
|||
String antwort3 = "TestAntwort"; |
|||
String antwort4 = "TestAntwort"; |
|||
|
|||
String Erwartet = "TestName/TestFrage/TestAntwort;TestAntwort;TestAntwort;TestAntwort"; |
|||
|
|||
String Ergebnis = WorkingObjekt.makeString(name,frage,antwort1,antwort2,antwort3,antwort4); |
|||
|
|||
assertEquals("Name Frage und alle Antworten" , Erwartet, Ergebnis); |
|||
} |
|||
|
|||
public void makeString_ohneName() { |
|||
Vokabelkarte WorkingObjekt = workingObjekt; |
|||
|
|||
String name = ""; |
|||
String frage = "TestFrage"; |
|||
String antwort1 = "TestAntwort"; |
|||
String antwort2 = "TestAntwort"; |
|||
String antwort3 = "TestAntwort"; |
|||
String antwort4 = "TestAntwort"; |
|||
|
|||
String Erwartet = "TestFrage/TestAntwort;TestAntwort;TestAntwort;TestAntwort"; |
|||
|
|||
String Ergebnis = WorkingObjekt.makeString(name,frage,antwort1,antwort2,antwort3,antwort4); |
|||
|
|||
assertEquals("Frage und alle Antworten" , Erwartet, Ergebnis); |
|||
|
|||
} |
|||
|
|||
@Test |
|||
public void makeStringReturnsStringNichtKorrekt() { |
|||
Vokabelkarte WorkingObjekt = workingObjekt; |
|||
|
|||
String name = "TestName"; |
|||
String frage = ""; |
|||
String antwort1 = ""; |
|||
String antwort2 = ""; |
|||
String antwort3 = "TestAntwort"; |
|||
String antwort4 = "TestAntwort"; |
|||
|
|||
String Erwartet = "TestName/TestAntwort;TestAntwort"; |
|||
|
|||
String Ergebnis = WorkingObjekt.makeString(name,frage,antwort1,antwort2,antwort3,antwort4); |
|||
|
|||
assertEquals("Name und drei Antworten" , Erwartet, Ergebnis); |
|||
} |
|||
|
|||
@Test |
|||
public void makeStringReturns_Leer() { |
|||
Vokabelkarte WorkingObjekt = workingObjekt; |
|||
|
|||
String name = ""; |
|||
String frage = ""; |
|||
String antwort1 = ""; |
|||
String antwort2 = ""; |
|||
String antwort3 = ""; |
|||
String antwort4 = ""; |
|||
|
|||
String Erwartet = ""; |
|||
|
|||
String Ergebnis = WorkingObjekt.makeString(name,frage,antwort1,antwort2,antwort3,antwort4); |
|||
|
|||
assertEquals("leer" , Erwartet, Ergebnis); |
|||
} |
|||
|
|||
@Test |
|||
public void makeStringReturnsStringUnvolständigKeineFrage() { |
|||
Vokabelkarte WorkingObjekt = workingObjekt; |
|||
|
|||
|
|||
String name = "TestName"; |
|||
String frage = ""; |
|||
String antwort1 = "TestAntwort"; |
|||
String antwort2 = "TestAntwort"; |
|||
String antwort3 = "TestAntwort"; |
|||
String antwort4 = "TestAntwort"; |
|||
|
|||
String Erwartet = "TestName/TestAntwort;TestAntwort;TestAntwort;TestAntwort"; |
|||
|
|||
String Ergebnis = WorkingObjekt.makeString(name,frage,antwort1,antwort2,antwort3,antwort4); |
|||
|
|||
assertEquals("Name und alle Antworten" , Erwartet, Ergebnis); |
|||
} |
|||
} |
@ -0,0 +1,421 @@ |
|||
package com.ugsbo.auslandssemester; |
|||
|
|||
import static org.junit.Assert.*; |
|||
|
|||
import org.junit.After; |
|||
import org.junit.AfterClass; |
|||
import org.junit.Before; |
|||
import org.junit.BeforeClass; |
|||
import org.junit.Test; |
|||
|
|||
import com.ugsbo.entscheider.Entscheider; |
|||
|
|||
public class JUnitTestAusslandssemesterSitzung { |
|||
|
|||
//Tests zu Methode kategorieDestination |
|||
// USA als Destination |
|||
@Test |
|||
public void KategorieDestinationUSA() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 2, "USA"); |
|||
String erwartet = "USA"; |
|||
String b = test.kategorieDestination(); |
|||
assertEquals("Antwortstring sollte USA sein", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// Asien als Destination |
|||
@Test |
|||
public void KategorieDestinationAsien() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 2, "Asien"); |
|||
String erwartet = "Asien"; |
|||
String b = test.kategorieDestination(); |
|||
assertEquals("Antwortstring sollte Asien sein", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// Neuseeland als Destination |
|||
@Test |
|||
public void KategorieDestinationNeuseeland() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 2, "Neuseeland"); |
|||
String erwartet = "Asien"; |
|||
String b = test.kategorieDestination(); |
|||
assertEquals("Antwortstring sollte Asien sein", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// Australien als Destination |
|||
@Test |
|||
public void KategorieDestinationAustralien() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 2, "Australien"); |
|||
String erwartet = "Asien"; |
|||
String b = test.kategorieDestination(); |
|||
assertEquals("Antwortstring sollte Asien sein", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// Europa als Destination |
|||
@Test |
|||
public void KategorieDestinationEuropa() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 2, "Europa"); |
|||
String erwartet = "Europa"; |
|||
String b = test.kategorieDestination(); |
|||
assertEquals("Antwortstring sollte Europa sein", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// Tests zu Methode kategorieInMonaten |
|||
// mehr als 12 Moante |
|||
@Test |
|||
public void KategorieInMonatenGroesserZwoelf() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 13, "Europa"); |
|||
int erwartet = 4; |
|||
int b = test.kategorieInMonaten(); |
|||
assertEquals("erwartet int 4", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// weniger als drei Monate |
|||
@Test |
|||
public void KategorieInMonatenKleinerDrei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 2, "Europa"); |
|||
int erwartet = 1; |
|||
int b = test.kategorieInMonaten(); |
|||
assertEquals("erwartet int 4", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// zwischne zwei und fuenf |
|||
@Test |
|||
public void KategorieInMonatenZwischenZweiFuenf() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 4, "Europa"); |
|||
int erwartet = 2; |
|||
int b = test.kategorieInMonaten(); |
|||
assertEquals("erwartet int 4", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// zwischne fuenf und zwoelf |
|||
@Test |
|||
public void KategorieInMonatenZwischenFuenfZwoelf() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 12, "Europa"); |
|||
int erwartet = 3; |
|||
int b = test.kategorieInMonaten(); |
|||
assertEquals("erwartet int 4", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// Tests zu Methode learningAgreement |
|||
|
|||
@Test |
|||
public void learningAgreementTest1() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 13, "Europa"); |
|||
String erwartet = "Jetzt musst du dich noch nicht über das Learning Agreement informieren."; |
|||
String b = test.learningAgreement(4); |
|||
assertEquals("erwartet Antwortstring", erwartet, b); |
|||
|
|||
} |
|||
|
|||
@Test |
|||
public void learningAgreementTest2() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 12, "Europa"); |
|||
String erwartet = "Jetzt musst du dich noch nicht über das Learning Agreement informieren."; |
|||
String b = test.learningAgreement(3); |
|||
assertEquals("erwartet Antwortstring", erwartet, b); |
|||
|
|||
} |
|||
|
|||
@Test |
|||
public void learningAgreementTest3() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 5, "Europa"); |
|||
String erwartet = "Jetzt solltest du dich über das Learning Agreement informieren. Was musst du wissen? Wer muss es unterzeichnen? Wo musst du es abgeben?"; |
|||
; |
|||
String b = test.learningAgreement(2); |
|||
assertEquals("erwartet Antwortstring", erwartet, b); |
|||
|
|||
} |
|||
|
|||
@Test |
|||
public void learningAgreementTest4() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 1, "Europa"); |
|||
String erwartet = "Wenn du jetzt noch kein Learning Agreement hast ist das seltsam. Frag so schnell es geht mal jemanden ob du eins brauchst."; |
|||
String b = test.learningAgreement(1); |
|||
assertEquals("erwartet Antwortstring", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// Tests zur Methode wohnen |
|||
@Test |
|||
public void wohnenTest1() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 1, "Europa"); |
|||
String erwartet = "Jetzt ist es schon fast zu spät um nach einer Wohnung zu suchen"; |
|||
String b = test.wohnen(1); |
|||
assertEquals("erwartet ein Antwortstring", erwartet, b); |
|||
|
|||
} |
|||
|
|||
@Test |
|||
public void wohnenTest2() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 5, "Europa"); |
|||
String erwartet = "Jetzt wird es höchste Zeit nach einer Wohung zu schauen."; |
|||
String b = test.wohnen(2); |
|||
assertEquals("erwartet ein Antwortstring", erwartet, b); |
|||
|
|||
} |
|||
|
|||
@Test |
|||
public void wohnenTest3() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 12, "Europa"); |
|||
String erwartet = "Jetzt informier dich definitiv schon mal wie es mit Wohnen ist. Manchmal gibt es Webseiten auf denen man über die Zeit Punkte sammelt."; |
|||
String b = test.wohnen(3); |
|||
assertEquals("erwartet ein Antwortstring", erwartet, b); |
|||
|
|||
} |
|||
|
|||
@Test |
|||
public void wohnenTest4() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 15, "Europa"); |
|||
String erwartet = "Schau dich am besten schon mal nach Wohnungen um. Manchmal gibt es Webseiten auf denen man über die Zeit Punkte sammelt."; |
|||
String b = test.wohnen(4); |
|||
assertEquals("erwartet ein Antwortstring", erwartet, b); |
|||
|
|||
} |
|||
|
|||
// Tests zur Methode packen |
|||
|
|||
@Test |
|||
public void packenTest1() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 1, "Europa"); |
|||
String erwartet = "Jetzt solltest du definitiv eine Liste schreiben und so langsam mal anfangen."; |
|||
String b = test.packen(1); |
|||
assertEquals("erwartet ein Antwortstring", erwartet, b); |
|||
|
|||
} |
|||
|
|||
@Test |
|||
public void packenTest2() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 6, "Europa"); |
|||
String erwartet = "Wenn du magst kannst schonmal anfangen eine Liste zu schreiben."; |
|||
String b = test.packen(2); |
|||
assertEquals("erwartet ein Antwortstring", erwartet, b); |
|||
} |
|||
|
|||
@Test |
|||
public void packenTest3() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 6, "Europa"); |
|||
String erwartet = "Kein Stress. DU hast noch eine Ewigkeit Zeit zum packen."; |
|||
String b = test.packen(3); |
|||
assertEquals("erwartet ein Antwortstring", erwartet, b); |
|||
} |
|||
|
|||
@Test |
|||
public void packenTest4() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 6, "Europa"); |
|||
String erwartet = "Kein Stress. DU hast noch eine Ewigkeit Zeit zum packen."; |
|||
String b = test.packen(4); |
|||
assertEquals("erwartet ein Antwortstring", erwartet, b); |
|||
} |
|||
|
|||
// Tests zur Methode deadline |
|||
|
|||
// kategorieZeit = 1, kategorieZiel = USA |
|||
|
|||
@Test |
|||
public void deadlineUSAEins() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 2, "USA"); |
|||
String erwartet = "Es tut mir Leid, aber du bist zu spät dran. Alle Deadlines sind durch."; |
|||
String c = test.deadline(1, "USA"); |
|||
assertEquals("erwartet einen Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
// kategorieZeit = 1, kategorieZiel = Asien |
|||
@Test |
|||
public void deadlineAsienEins() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 2, "Asien"); |
|||
String erwartet = "Es tut mir Leid, aber du bist zu spät dran. Alle Deadlines sind durch."; |
|||
String c = test.deadline(1, "Asien"); |
|||
assertEquals("erwartet einen Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
@Test |
|||
public void deadlineUSAZwei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 4, "USA"); |
|||
String erwartet = "Die Bewerbungsdeadlines sind hier wahrscheinlich schon durch. Stipendien könnten aber noch gehen"; |
|||
String c = test.deadline(2, "USA"); |
|||
assertEquals("erwartet einen Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
@Test |
|||
public void deadlineAsienZwei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 4, "Asien"); |
|||
String erwartet = "Die Bewerbungsdeadlines sind hier wahrscheinlich schon durch. Stipendien könnten aber noch gehen"; |
|||
String c = test.deadline(2, "Asien"); |
|||
assertEquals("erwartet einen Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
@Test |
|||
public void deadlineUSADrei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 6, "USA"); |
|||
String erwartet = "Jetzt solltest du dich auf jeden Fall über die Deadlines informieren."; |
|||
String c = test.deadline(3, "USA"); |
|||
assertEquals("erwartet Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
@Test |
|||
public void deadlineAsienDrei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 6, "Asien"); |
|||
String erwartet = "Jetzt solltest du dich auf jeden Fall über die Deadlines informieren."; |
|||
String c = test.deadline(3, "Asien"); |
|||
assertEquals("erwartet Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
@Test |
|||
public void deadlineUSAVier() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 13, "USA"); |
|||
String erwartet = "Zu diesem Zeitraum ist es sinnvoll sich über die entsprechenden Deadlines zu informieren."; |
|||
String c = test.deadline(4, "USA"); |
|||
assertEquals("erwartet Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
@Test |
|||
public void deadlineAsienVier() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 13, "Asien"); |
|||
String erwartet = "Zu diesem Zeitraum ist es sinnvoll sich über die entsprechenden Deadlines zu informieren."; |
|||
String c = test.deadline(4, "Asien"); |
|||
assertEquals("erwartet Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
@Test |
|||
public void deadlineEuropaEins() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 1, "Europa"); |
|||
String erwartet = "Es tut mir Leid, aber du bist zu spät dran. Alle Deadlines sind durch."; |
|||
String c = test.deadline(1, "Europa"); |
|||
assertEquals("erwartet Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
@Test |
|||
public void deadlineEuropaZwei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 4, "Europa"); |
|||
String erwartet = "Jetzt aber wirklich zügig. Die Deadlines sind bestimmt noch nicht ganz abgelaufen."; |
|||
String c = test.deadline(2, "Europa"); |
|||
assertEquals("erwartet Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
@Test |
|||
public void deadlineEuropaDrei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 6, "Europa"); |
|||
String erwartet = "Jetzt wäre es wichtig sich über Deadlines zu informieren."; |
|||
String c = test.deadline(3, "Europa"); |
|||
assertEquals("erwartet Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
@Test |
|||
public void deadlineEuropaVier() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 13, "Europa"); |
|||
String erwartet = "Zu diesem Zeitpunkt musst du dich noch nicht um Deadlines sorgen. Mal schauen schadet aber nicht."; |
|||
String c = test.deadline(4, "Europa"); |
|||
assertEquals("erwartet Antwortstring", erwartet, c); |
|||
} |
|||
|
|||
// Testfälle zur Methode finanzierung() |
|||
|
|||
@Test |
|||
public void finanzierungAsienEins() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 1,"Asien"); |
|||
String e = "Selbst wenn du bisher noch gar nicht an die Finanzierung gedacht hast solltest du es jetzt tun. Besser spät als nie."; |
|||
String a = test.finanzierung(1, "Asien"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungUSAEins() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 1,"USA"); |
|||
String e = "Selbst wenn du bisher noch gar nicht an die Finanzierung gedacht hast solltest du es jetzt tun. Besser spät als nie."; |
|||
String a = test.finanzierung(1, "USA"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungAsienZwei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 4,"Asien"); |
|||
String e = "Wenn du dich noch nicht um die Finanzierung gekümmert hast, dann musst du dich jetzt aber ran halten."; |
|||
String a = test.finanzierung(2, "USA"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungUSAZwei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 4,"USA"); |
|||
String e = "Wenn du dich noch nicht um die Finanzierung gekümmert hast, dann musst du dich jetzt aber ran halten."; |
|||
String a = test.finanzierung(2, "USA"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungAsienDrei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 6,"Asien"); |
|||
String e = "Jetzt musst du auf jeden Fall überlegen wie du das finanziern willst. Sprich vielleicht mal mit deinen Eltern oder such nach Stipendien"; |
|||
String a = test.finanzierung(3, "Asien"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungUSADrei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 6,"USA"); |
|||
String e = "Jetzt musst du auf jeden Fall überlegen wie du das finanziern willst. Sprich vielleicht mal mit deinen Eltern oder such nach Stipendien"; |
|||
String a = test.finanzierung(3, "USA"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungAsienVier() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 13,"Asien"); |
|||
String e = "Finanzierung ist keine leichte Sache, darüber kann man sich nie zu früh Gedanken machen. Stichwort: Stipendium."; |
|||
String a = test.finanzierung(4, "Asien"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungUSAVier() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 13,"USA"); |
|||
String e = "Finanzierung ist keine leichte Sache, darüber kann man sich nie zu früh Gedanken machen. Stichwort: Stipendium."; |
|||
String a = test.finanzierung(4, "USA"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungEuropaEins() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 1,"Europa"); |
|||
String e = "Wenn du ein Erasmus+ STipendium bekommst, dann wirst du noch einen Englischtest absolvieren und einen Vertrag unterschreiben müssen. Denk auch an deine Immatrikulationsbescheingung."; |
|||
String a = test.finanzierung(1, "Europa"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungEuropaZwei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 4,"Europa"); |
|||
String e = "Wenn du dich auf Ersamus beworben hast dann solltest du demnächst deine Rückmeldung bekommen."; |
|||
String a = test.finanzierung(2, "Europa"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungEuropaDrei() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 6,"Europa"); |
|||
String e = "Denk am besten schon mal ein bisschen an die Finanzierung. Frag an ob Erasmus für dich in Frage kommt."; |
|||
String a = test.finanzierung(3, "Europa"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
@Test |
|||
public void finanzierungEuropaVier() { |
|||
Sitzung test = new Sitzung("Mustermann", "Max", 13,"Europa"); |
|||
String e = "Über die Finanzierung kann man sich nie zu früh Gedanken machen. Aber bitte keine Hektik."; |
|||
String a = test.finanzierung(4, "Europa"); |
|||
assertEquals("erwartet Antwortstring", e, a); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,71 @@ |
|||
package com.ugsbo.complexnumcalc; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
import org.junit.Test; |
|||
|
|||
public class AbsoluteValueOfComplexNumbersTest { |
|||
|
|||
@Test |
|||
public void TheAbsoluteValueOfAComplexNumberWithOnlyARealPart_IsNotTheAbsoluteValueOfTheRealPart() { |
|||
ComplexNumber complexNumber = new ComplexNumber(Double.valueOf(4), Double.valueOf(0)); |
|||
Double expected = Double.valueOf(4); |
|||
|
|||
Double actual = complexNumber.absolutValueOf(); |
|||
|
|||
assertEquals("The absolute value of an complex number with only an real part should be the absolute value of that real part", expected, actual); |
|||
} |
|||
|
|||
@Test |
|||
public void TheAbsoluteValueOfAComplexNumberWithOnlyANegativeRealPart_IsNotTheAbsoluteValueOfTheRealPart() { |
|||
ComplexNumber complexNumber = new ComplexNumber(Double.valueOf(-4), Double.valueOf(0)); |
|||
Double expected = Double.valueOf(4); |
|||
|
|||
Double actual = complexNumber.absolutValueOf(); |
|||
|
|||
assertEquals("The absolute value of an complex number with only an negative real part should be the absolute value of that real part", expected, actual); |
|||
} |
|||
|
|||
@Test |
|||
public void TheAbsoluteValueOfAComplexNumber_IsNotTheAbsoluteValueOfIt() { |
|||
ComplexNumber complexNumber = new ComplexNumber(Double.valueOf(4), Double.valueOf(3)); |
|||
Double expected = Double.valueOf(5); |
|||
|
|||
Double actual = complexNumber.absolutValueOf(); |
|||
|
|||
assertEquals("The absolute value of an complex number should be the square root of the sum of real " + |
|||
"part times real part and imaginary part times imaginary part ", expected, actual); |
|||
} |
|||
|
|||
@Test |
|||
public void TheAbsoluteValueOfAComplexNumberWithNegativRealPart_IsNotTheAbsoluteValueOfIt() { |
|||
ComplexNumber complexNumber = new ComplexNumber(Double.valueOf(-4), Double.valueOf(3)); |
|||
Double expected = Double.valueOf(5); |
|||
|
|||
Double actual = complexNumber.absolutValueOf(); |
|||
|
|||
assertEquals("The absolute value of an complex number with negative real part should be the square root of the sum of real " + |
|||
"part times real part and imaginary part times imaginary part ", expected, actual); |
|||
} |
|||
|
|||
@Test |
|||
public void TheAbsoluteValueOfAComplexNumberWithNegativImaginaryPart_IsNotTheAbsoluteValueOfIt() { |
|||
ComplexNumber complexNumber = new ComplexNumber(Double.valueOf(4), Double.valueOf(-3)); |
|||
Double expected = Double.valueOf(5); |
|||
|
|||
Double actual = complexNumber.absolutValueOf(); |
|||
|
|||
assertEquals("The absolute value of an complex number with negative imaginary part should be the square root of the sum of real " + |
|||
"part times real part and imaginary part times imaginary part ", expected, actual); |
|||
} |
|||
|
|||
@Test |
|||
public void TheAbsoluteValueOfAComplexNumberWithNegativParts_IsNotTheAbsoluteValueOfIt() { |
|||
ComplexNumber complexNumber = new ComplexNumber(Double.valueOf(-4), Double.valueOf(-3)); |
|||
Double expected = Double.valueOf(5); |
|||
|
|||
Double actual = complexNumber.absolutValueOf(); |
|||
|
|||
assertEquals("The absolute value of an complex number with negative parts should be the square root of the sum of real " + |
|||
"part times real part and imaginary part times imaginary part ", expected, actual); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.ugsbo.complexnumcalc; |
|||
|
|||
import static org.hamcrest.MatcherAssert.assertThat; |
|||
import static org.hamcrest.Matchers.*; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
public class AddComplexNumbersTest { |
|||
|
|||
@Test |
|||
public void addingTwoComplexNumbersWithoutImaginaryPart() { |
|||
ComplexNumber firstAddend = new ComplexNumber(Double.valueOf(5), Double.valueOf(0)); |
|||
ComplexNumber secoundAddend = new ComplexNumber(Double.valueOf(6), Double.valueOf(0)); |
|||
ComplexNumber expected = new ComplexNumber(Double.valueOf(11), Double.valueOf(0)); |
|||
|
|||
ComplexNumber sum = firstAddend.add(secoundAddend); |
|||
|
|||
assertThat("Dont sum to the sum", sum, equalTo(expected)); |
|||
} |
|||
|
|||
@Test |
|||
public void addingTwoComplexNumbersWithImaginaryPart() { |
|||
ComplexNumber firstAddend = new ComplexNumber(Double.valueOf(5), Double.valueOf(3)); |
|||
ComplexNumber secoundAddend = new ComplexNumber(Double.valueOf(6), Double.valueOf(4)); |
|||
ComplexNumber expected = new ComplexNumber(Double.valueOf(11), Double.valueOf(7)); |
|||
|
|||
ComplexNumber sum = firstAddend.add(secoundAddend); |
|||
|
|||
assertThat("Dont sum to the sum", sum, equalTo(expected)); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.ugsbo.complexnumcalc; |
|||
|
|||
import static org.hamcrest.MatcherAssert.assertThat; |
|||
import static org.hamcrest.Matchers.*; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
public class DivideComplexNumbersTest { |
|||
|
|||
@Test |
|||
public void divideTwoComplexNumbersWithoutImaginaryPart() { |
|||
ComplexNumber dividend = new ComplexNumber(Double.valueOf(30), Double.valueOf(0)); |
|||
ComplexNumber divisor = new ComplexNumber(Double.valueOf(6), Double.valueOf(0)); |
|||
ComplexNumber expected = new ComplexNumber(Double.valueOf(5), Double.valueOf(0)); |
|||
|
|||
ComplexNumber quotient = dividend.divide(divisor); |
|||
|
|||
assertThat("The quotient is not as expected", quotient, equalTo(expected)); |
|||
} |
|||
|
|||
@Test |
|||
public void divideTwoComplexNumbersWithImaginaryPart() { |
|||
ComplexNumber dividend = new ComplexNumber(Double.valueOf(30), Double.valueOf(28)); |
|||
ComplexNumber divisor = new ComplexNumber(Double.valueOf(6), Double.valueOf(2)); |
|||
ComplexNumber expected = new ComplexNumber(Double.valueOf(5.9), Double.valueOf(2.7)); |
|||
|
|||
ComplexNumber quotient = dividend.divide(divisor); |
|||
|
|||
assertThat("The quotient is not as expected", quotient, equalTo(expected)); |
|||
} |
|||
} |
@ -0,0 +1,69 @@ |
|||
package com.ugsbo.complexnumcalc; |
|||
|
|||
import static org.junit.Assert.assertFalse; |
|||
import static org.junit.Assert.assertTrue; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
public class EqualsComplexNumbersTest { |
|||
|
|||
@Test |
|||
public void TwoEqualNumbersWithOnlyRealPart_AreNotDetectedAsEqual() { |
|||
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(0)); |
|||
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(0)); |
|||
|
|||
boolean actual = firstNumber.equals(secoundNumber); |
|||
|
|||
assertTrue("TwoEqualNumbersShouldBeEqual", actual); |
|||
} |
|||
|
|||
@Test |
|||
public void TwoNotEqualNumbersWithOnlyRealPart_AreDetectedAsEqual() { |
|||
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(0)); |
|||
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(6), Double.valueOf(0)); |
|||
|
|||
boolean actual = firstNumber.equals(secoundNumber); |
|||
|
|||
assertFalse("TwoNotEqualNumbersShouldNotBeEqual", actual); |
|||
} |
|||
|
|||
@Test |
|||
public void TwoEqualNumbersWithOnlyImaginaryPart_AreNotDetectedAsEqual() { |
|||
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(0), Double.valueOf(5)); |
|||
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(0), Double.valueOf(5)); |
|||
|
|||
boolean actual = firstNumber.equals(secoundNumber); |
|||
|
|||
assertTrue("TwoEqualComplexNumbersShouldBeEqual", actual); |
|||
} |
|||
|
|||
@Test |
|||
public void TwoNotEqualNumbersWithOnlyImaginaryPart_AreDetectedAsEqual() { |
|||
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(0), Double.valueOf(5)); |
|||
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(0), Double.valueOf(6)); |
|||
|
|||
boolean actual = firstNumber.equals(secoundNumber); |
|||
|
|||
assertFalse("TwoNotEqualComplexNumbersShouldNotBeEqual", actual); |
|||
} |
|||
|
|||
@Test |
|||
public void TwoEqualComplexNumbers_AreNotDetectedAsEqual() { |
|||
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(5)); |
|||
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(5)); |
|||
|
|||
boolean actual = firstNumber.equals(secoundNumber); |
|||
|
|||
assertTrue("TwoEqualComplexNumbersShouldBeEqual", actual); |
|||
} |
|||
|
|||
@Test |
|||
public void TwoNotEqualComplexNumbers_AreDetectedAsEqual() { |
|||
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(5)); |
|||
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(6), Double.valueOf(6)); |
|||
|
|||
boolean actual = firstNumber.equals(secoundNumber); |
|||
|
|||
assertFalse("TwoNotEqualComplexNumbersShouldNotBeEqual", actual); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.ugsbo.complexnumcalc; |
|||
|
|||
import static org.hamcrest.MatcherAssert.assertThat; |
|||
import static org.hamcrest.Matchers.*; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
public class MultiplyComplexNumbersTest { |
|||
|
|||
@Test |
|||
public void multiplyTwoComplexNumbersWithoutImaginaryPart() { |
|||
ComplexNumber firstFaktor = new ComplexNumber(Double.valueOf(5), Double.valueOf(0)); |
|||
ComplexNumber secoundFaktor = new ComplexNumber(Double.valueOf(6), Double.valueOf(0)); |
|||
ComplexNumber expected = new ComplexNumber(Double.valueOf(30), Double.valueOf(0)); |
|||
|
|||
ComplexNumber product = firstFaktor.multiply(secoundFaktor); |
|||
|
|||
assertThat("The product is not as expected", product, equalTo(expected)); |
|||
} |
|||
|
|||
@Test |
|||
public void multiplyTwoComplexNumbersWithImaginaryPart() { |
|||
ComplexNumber firstFaktor = new ComplexNumber(Double.valueOf(5), Double.valueOf(3)); |
|||
ComplexNumber secoundFaktor = new ComplexNumber(Double.valueOf(6), Double.valueOf(2)); |
|||
ComplexNumber expected = new ComplexNumber(Double.valueOf(24.0), Double.valueOf(28.0)); |
|||
|
|||
ComplexNumber product = firstFaktor.multiply(secoundFaktor); |
|||
|
|||
assertThat("The product is not as expected", product, equalTo(expected)); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.ugsbo.complexnumcalc; |
|||
|
|||
import static org.hamcrest.MatcherAssert.assertThat; |
|||
import static org.hamcrest.Matchers.*; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
public class SubstractComplexNumbersTest { |
|||
|
|||
@Test |
|||
public void substractTwoComplexNumbersWithoutImaginaryPart() { |
|||
ComplexNumber minuend = new ComplexNumber(Double.valueOf(5), Double.valueOf(0)); |
|||
ComplexNumber subtrahend = new ComplexNumber(Double.valueOf(6), Double.valueOf(0)); |
|||
ComplexNumber expected = new ComplexNumber(Double.valueOf(-1), Double.valueOf(0)); |
|||
|
|||
ComplexNumber difference = minuend.substract(subtrahend); |
|||
|
|||
assertThat("The difference is not as expected", difference, equalTo(expected)); |
|||
} |
|||
|
|||
@Test |
|||
public void substractTwoComplexNumbersWithImaginaryPart() { |
|||
ComplexNumber minuend = new ComplexNumber(Double.valueOf(5), Double.valueOf(5)); |
|||
ComplexNumber subtrahend = new ComplexNumber(Double.valueOf(6), Double.valueOf(4)); |
|||
ComplexNumber expected = new ComplexNumber(Double.valueOf(-1), Double.valueOf(1)); |
|||
|
|||
ComplexNumber difference = minuend.substract(subtrahend); |
|||
|
|||
assertThat("The difference is not as expected", difference, equalTo(expected)); |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.ugsbo.complexnumcalc; |
|||
|
|||
import static org.hamcrest.MatcherAssert.assertThat; |
|||
import static org.hamcrest.Matchers.*; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
public class conjugationOfComplexNumbersTest { |
|||
|
|||
@Test |
|||
public void TheConjugatedComplexNumberOfAComplexNumberWithOnlyARealPartShouldBeTheRealPart_ButItIsNot() { |
|||
Double realPart = Double.valueOf(4); |
|||
Double imaginaryPart = Double.valueOf(0); |
|||
ComplexNumber complexNumber = new ComplexNumber(realPart, imaginaryPart); |
|||
ComplexNumber expected = new ComplexNumber(realPart, imaginaryPart); |
|||
|
|||
ComplexNumber actual = complexNumber.conjugationOf(); |
|||
|
|||
assertThat("The conjugated complex Number of a complex number with only a real part is the real part", expected, equalTo(actual)); |
|||
} |
|||
|
|||
@Test |
|||
public void TheConjugatedComplexNumberOfAComplexNumberShouldBeTheComplexNumberWithSwapedSignImaginaryPart_ButItIsNot() { |
|||
Double realPart = Double.valueOf(4); |
|||
Double imaginaryPart = Double.valueOf(5); |
|||
ComplexNumber complexNumber = new ComplexNumber(realPart, imaginaryPart); |
|||
ComplexNumber expected = new ComplexNumber(realPart, -imaginaryPart); |
|||
|
|||
ComplexNumber actual = complexNumber.conjugationOf(); |
|||
|
|||
assertThat("The conjugated complex number of a complex number is the complex number with swaped sign in the imaginary part", expected, equalTo(actual)); |
|||
} |
|||
} |
@ -0,0 +1,80 @@ |
|||
package com.ugsbo.entscheider; |
|||
|
|||
import static org.junit.Assert.*; |
|||
|
|||
|
|||
import org.junit.Assert; |
|||
import org.junit.Test; |
|||
|
|||
public class JUnitEntscheiderErgebnisTest { |
|||
|
|||
|
|||
//Testet den Fall Ergebnis ist zwischen 5 und 15 |
|||
|
|||
@Test |
|||
public void ergebnisZwischenFuenfUndFuenfzehn() { |
|||
//Eingabe der Werte zu den Fragen. Das erwartete Ergebnis zwischen 5 und 15 (jeweils inklusiv) |
|||
//deshalb muss Rückgabewert: "Naja, dann geh halt nach Hause und ruh dich aus." sein |
|||
int alter = 21; |
|||
int lernen = 1; |
|||
int gelb = 1; |
|||
int apfel = 3; |
|||
int mot = 2; |
|||
int harry = 1; |
|||
int fruehstueck = 1; |
|||
int anzahl = 4; |
|||
//erwarteter String |
|||
String erwartet = "Naja, dann geh halt nach Hause und ruh dich aus."; |
|||
//ausführen der Methode |
|||
String b = Entscheider.ergebnis(alter, lernen, gelb, apfel, mot, harry, fruehstueck, anzahl); |
|||
//stimmt es mit dem erwartetem überein? |
|||
assertEquals("Anwortstring",erwartet,b); |
|||
} |
|||
//Testet den Fall ergebnis ist größer 15 |
|||
@Test |
|||
public void ergebnisTest() { |
|||
//Eingabe der Werte zu den Fragen. Das erwartete Ergebnis ist größer 5 |
|||
//deshalb muss Rückgabewert: "Jetzt wieder gehen? Dann bist du doch voellig umsonst aufgestanden. Geh einfach hin." sein |
|||
int alter = 29; |
|||
int lernen = 0; |
|||
int gelb = 1; |
|||
int apfel = 3; |
|||
int mot = 2; |
|||
int harry = 0; |
|||
int fruehstueck = 1; |
|||
int anzahl = 2; |
|||
//erwarteter String |
|||
String erwartet = "Jetzt wieder gehen? Dann bist du doch voellig umsonst aufgestanden. Geh einfach hin."; |
|||
//ausführen der Methode |
|||
String c = Entscheider.ergebnis(alter, lernen, gelb, apfel, mot, harry, fruehstueck, anzahl); |
|||
//Stimmt Ergebnis |
|||
assertEquals("Anwortstring für größer 5",erwartet,c); |
|||
|
|||
} |
|||
//Testet den Fall ergebnis ist kleiner 5 |
|||
|
|||
@Test |
|||
public void ergebnisKleinerFuenf() { |
|||
//Eingabe der Werte zu den Fragen. Das erwartete Ergebnis ist kleiner 5 |
|||
//deshalb muss Rückgabewert: "Ich kann doch nicht fuer dich entscheiden, dass musst du schon selber wissen." sein |
|||
int alter = 1; |
|||
int lernen = 1; |
|||
int gelb = 1; |
|||
int apfel = 1; |
|||
int mot = 1; |
|||
int harry = 1; |
|||
int fruehstueck = 1; |
|||
int anzahl = 1; |
|||
//erwarteter String |
|||
String erwartet ="Ich kann doch nicht fuer dich entscheiden, dass musst du schon selber wissen."; |
|||
//ausführen der Methode |
|||
String a = Entscheider.ergebnis(alter, lernen, gelb, apfel, mot, harry, fruehstueck, anzahl); |
|||
//stimmt Ergebnis? |
|||
assertEquals("Anwortstring für kleiner 5",erwartet,a); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1 @@ |
|||
package com.ugsbo.entscheider; |
@ -0,0 +1,156 @@ |
|||
package com.ugsbo.matrixcalc; |
|||
|
|||
import static org.junit.Assert.assertArrayEquals; |
|||
import static org.junit.Assert.assertFalse; |
|||
import static org.junit.Assert.assertTrue; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
|
|||
/** |
|||
* Tests the funktionality to add and substract two matricies |
|||
*/ |
|||
public class MatrixAdditionAndSubstractionTest { |
|||
|
|||
private MatrixCalcMath matrixMath; |
|||
|
|||
@Before |
|||
public void setup() { |
|||
matrixMath = new MatrixCalcMath(); |
|||
} |
|||
|
|||
@Test |
|||
public void twoMatriciesHaveTheSameDimensions() { |
|||
double[][] matrixA = new double[1][1]; |
|||
double[][] matrixB = new double[1][1]; |
|||
|
|||
boolean result = matrixMath.checkIfMatriciesAreTheSameDimension(matrixA, matrixB); |
|||
|
|||
assertTrue("Two Matricies with the same Dimension were not detected as that", result); |
|||
} |
|||
|
|||
@Test |
|||
public void twoMatriciesDONOTHaveTheSameDimensions() { |
|||
double[][] matrixA = new double[2][1]; |
|||
double[][] matrixB = new double[1][1]; |
|||
|
|||
boolean result = matrixMath.checkIfMatriciesAreTheSameDimension(matrixA, matrixB); |
|||
|
|||
assertFalse("Two Matricies without the same Dimension were detected as that", result); |
|||
} |
|||
|
|||
@Test |
|||
public void addTwoMatriciesWithSameContent() { |
|||
double[][] matrixA = { { 1.0, 1.0 }, { 1.0, 1.0 } }; |
|||
double[][] matrixB = { { 1.0, 1.0 }, { 1.0, 1.0 } }; |
|||
double[][] matrixC = { { 2.0, 2.0 }, { 2.0, 2.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixAddition(matrixA, matrixB); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void addTwoMatriciesWithDiffrentContent() { |
|||
double[][] matrixA = { { 7.0, 3.0 }, { 2.0, 9.0 } }; |
|||
double[][] matrixB = { { 6.0, 3.0 }, { 7.0, 11.0 } }; |
|||
double[][] matrixC = { { 13.0, 6.0 }, { 9.0, 20.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixAddition(matrixA, matrixB); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
public void tryToAddTowEmptyMatricies() { |
|||
// A(0,0) B(0,0) => IllegalArgumentException |
|||
double[][] matrixA = new double[0][0]; |
|||
double[][] matrixB = new double[0][0]; |
|||
|
|||
matrixMath.matrixAddition(matrixA, matrixB); |
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
public void tryToAddTowNullMatrices() { |
|||
// A(0,0) B(0,0) => IllegalArgumentException |
|||
double[][] matrixA = null; |
|||
double[][] matrixB = null; |
|||
|
|||
matrixMath.matrixAddition(matrixA, matrixB); |
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
public void tryToAddTowMatricesWithDifferentDimensions() { |
|||
// A(0,0) B(0,0) => IllegalArgumentException |
|||
double[][] matrixA = { { 1.0, 2.0 } }; |
|||
double[][] matrixB = { { 1.0 }, { 2.0 } }; |
|||
|
|||
matrixMath.matrixAddition(matrixA, matrixB); |
|||
} |
|||
|
|||
@Test |
|||
public void substractTwoMatriciesWithSameContent() { |
|||
double[][] matrixA = { { 1.0, 1.0 }, { 1.0, 1.0 } }; |
|||
double[][] matrixB = { { 1.0, 1.0 }, { 1.0, 1.0 } }; |
|||
double[][] matrixC = { { 0.0, 0.0 }, { 0.0, 0.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixSubstraction(matrixA, matrixB); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void substractTwoMatriciesWithDiffrentContent() { |
|||
double[][] matrixA = { { 1.0, 2.0 }, { 3.0, 4.0 } }; |
|||
double[][] matrixB = { { 5.0, 6.0 }, { 7.0, 8.0 } }; |
|||
double[][] matrixC = { { -4.0, -4.0 }, { -4.0, -4.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixSubstraction(matrixA, matrixB); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void substractTwoMatriciesWithNegativeContent() { |
|||
double[][] matrixA = { { -1.0, -2.0 }, { -3.0, -4.0 } }; |
|||
double[][] matrixB = { { 5.0, 6.0 }, { 7.0, 8.0 } }; |
|||
double[][] matrixC = { { -6.0, -8.0 }, { -10.0, -12.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixSubstraction(matrixA, matrixB); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
public void tryToSubstractTowEmptyMatricies() { |
|||
// A(0,0) B(0,0) => IllegalArgumentException |
|||
double[][] matrixA = new double[0][0]; |
|||
double[][] matrixB = new double[0][0]; |
|||
|
|||
matrixMath.matrixSubstraction(matrixA, matrixB); |
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
public void tryToSubstractTowNullMatrices() { |
|||
// A(0,0) B(0,0) => IllegalArgumentException |
|||
double[][] matrixA = null; |
|||
double[][] matrixB = null; |
|||
|
|||
matrixMath.matrixSubstraction(matrixA, matrixB); |
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
public void tryToSubstractTowMatricesWithDifferentDimensions() { |
|||
// A(0,0) B(0,0) => IllegalArgumentException |
|||
double[][] matrixA = { { 1.0, 2.0 } }; |
|||
double[][] matrixB = { { 1.0 }, { 2.0 } }; |
|||
|
|||
matrixMath.matrixSubstraction(matrixA, matrixB); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,61 @@ |
|||
package com.ugsbo.matrixcalc; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
|
|||
/** |
|||
* Tests the funktionality to Calculate the Determinant of a Matrix. |
|||
*/ |
|||
public class MatrixCalcDeterminatTest { |
|||
|
|||
private MatrixCalcMath matrixMath; |
|||
|
|||
@Before |
|||
public void setup() { |
|||
matrixMath = new MatrixCalcMath(); |
|||
} |
|||
|
|||
@Test |
|||
public void CalculatesTheDeterminanteOfA2by2Matrix() { |
|||
// A(2,2) |
|||
double[][] matrixA = { { 1.0, 2.0 }, { 3.0, 4.0 } }; |
|||
double determinat = -2.0; |
|||
double delta = 0.01; |
|||
|
|||
double result = matrixMath.calcDeterminat(matrixA); |
|||
|
|||
assertEquals("The Determinant is not as it should be", determinat, result, delta); |
|||
} |
|||
|
|||
@Test |
|||
public void CalculatesTheDeterminanteOfA3by3Matrix() { |
|||
// A(3,3) |
|||
double[][] matrixA = { { 1.0, 2.0, 1.0 }, { 3.0, 4.0, 0.0 }, { 5.0, 6.0, 0.0 } }; |
|||
double determinat = -2.0; |
|||
double delta = 0.01; |
|||
|
|||
double result = matrixMath.calcDeterminat(matrixA); |
|||
|
|||
assertEquals("The Determinant is not as it should be", determinat, result, delta); |
|||
|
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
public void tryToCalculateA4by4Matrix_ShouldResulInIllegalArgumentException() { |
|||
// A(4,4) |
|||
double[][] matrixA = { { 1.0, 2.0, 1.0, 0.0 }, { 3.0, 4.0, 0.0, 0.0 }, { 5.0, 6.0, 0.0, 0.0 }, |
|||
{ 5.0, 6.0, 0.0, 0.0 } }; |
|||
|
|||
matrixMath.calcDeterminat(matrixA); |
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
public void tryToCalculateANonQuadraticMatrix_SouldResulInIllegalArgumentException() { |
|||
// A(2,4) |
|||
double[][] matrixA = { { 5.0, 6.0, 0.0, 0.0 }, { 5.0, 6.0, 0.0, 0.0 } }; |
|||
|
|||
matrixMath.calcDeterminat(matrixA); |
|||
} |
|||
} |
@ -0,0 +1,170 @@ |
|||
package com.ugsbo.matrixcalc; |
|||
|
|||
import static org.junit.Assert.assertArrayEquals; |
|||
import static org.junit.Assert.assertEquals; |
|||
import static org.junit.Assert.assertFalse; |
|||
import static org.junit.Assert.assertTrue; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
|
|||
/** |
|||
* Tests how well worng input can be determent. |
|||
*/ |
|||
public class MatrixIOUtilsTest { |
|||
|
|||
private MatrixCalcIOUtils util; |
|||
|
|||
@Before |
|||
public void setup() { |
|||
util = new MatrixCalcIOUtils(); |
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
public void inputEmptySouldThrowAIllegalArgumentException() { |
|||
String input = ""; |
|||
|
|||
util.checkInput(input); |
|||
} |
|||
|
|||
@Test |
|||
public void checkIfA1by3MatrixIsValidInput() { |
|||
String input = "1 2 3"; |
|||
|
|||
try { |
|||
// act |
|||
util.checkInput(input); |
|||
|
|||
// assert |
|||
assertTrue("The 1 by 3 Matrix should be Matched as valid input.", true); |
|||
} catch (IllegalArgumentException e) { |
|||
assertFalse("The 1 by 3 Matrix should be Matched as valid input.", true); |
|||
} |
|||
} |
|||
|
|||
@Test |
|||
public void checkIfA2by3MatrixIsValidInput() { |
|||
// arrange |
|||
String input = "1 2 3\n1 2 3"; |
|||
|
|||
try { |
|||
// act |
|||
util.checkInput(input); |
|||
|
|||
// assert |
|||
assertTrue("The 2 by 3 Matrix should be Matched as valid input.", true); |
|||
} catch (IllegalArgumentException e) { |
|||
assertFalse("The 2 by 3 Matrix should be Matched as valid input.", true); |
|||
} |
|||
} |
|||
|
|||
@Test |
|||
public void checkIfA3by3MatrixIsValidInput() { |
|||
String input = "1 2 3\n1 2 3\n1 2 3"; |
|||
|
|||
try { |
|||
util.checkInput(input); |
|||
|
|||
assertTrue("The 3 by 3 Matrix should be Matched as valid input.", true); |
|||
} catch (IllegalArgumentException e) { |
|||
assertFalse("The 3 by 3 Matrix should be Matched as valid input.", true); |
|||
} |
|||
|
|||
} |
|||
|
|||
@Test |
|||
public void StringWithSingleDigitNumbersToMatrix_ReturnsEquivalentMatrix() { |
|||
String inputString = "1"; |
|||
double[][] expected = { { 1.0 } }; |
|||
|
|||
double[][] result = util.stringToMatrix(inputString); |
|||
|
|||
assertArrayEquals("The first row is not correct", expected[0], result[0], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void StringWithfourDigitNumbersToMatrix_ReturnsEquivalentMatrix() { |
|||
String inputString = "1 2\n3 4"; |
|||
double[][] expected = { { 1.0, 2.0 }, { 3.0, 4.0 } }; |
|||
|
|||
double[][] result = util.stringToMatrix(inputString); |
|||
|
|||
assertArrayEquals("The first row is not correct", expected[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", expected[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void StringWithSixDigitNumbersToMatrix_Returns1by6Matrix() { |
|||
String inputString = "1 2 3 4 5 6"; |
|||
double[][] expected = { { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 } }; |
|||
|
|||
double[][] result = util.stringToMatrix(inputString); |
|||
|
|||
assertArrayEquals("The first row is not correct", expected[0], result[0], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void StringWithSixDigitNumbersToMatrix_Returns2by3Matrix() { |
|||
String inputString = "1 2 3\n4 5 6"; |
|||
double[][] expected = { { 1.0, 2.0, 3.0 }, { 4.0, 5.0, 6.0 } }; |
|||
|
|||
double[][] result = util.stringToMatrix(inputString); |
|||
|
|||
assertArrayEquals("The first row is not correct", expected[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", expected[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void StringWithSixDigitNumbersToMatrix_Returns3by2Matrix() { |
|||
String inputString = "1 2\n3 4\n5 6"; |
|||
double[][] expected = { { 1.0, 2.0 }, { 3.0, 4.0 }, { 5.0, 6.0 } }; |
|||
|
|||
double[][] result = util.stringToMatrix(inputString); |
|||
|
|||
assertArrayEquals("The first row is not correct", expected[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", expected[1], result[1], 0.1); |
|||
assertArrayEquals("The therd row is not correct", expected[2], result[2], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void StringWithNineDigitNumbersToMatrix_Returns3by3Matrix() { |
|||
String inputString = "1 2 3\n4 5 6\n7 8 9"; |
|||
double[][] expected = { { 1.0, 2.0, 3.0 }, { 4.0, 5.0, 6.0 }, { 7.0, 8.0, 9.0 } }; |
|||
|
|||
double[][] result = util.stringToMatrix(inputString); |
|||
|
|||
assertArrayEquals("The first row is not correct", expected[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", expected[1], result[1], 0.1); |
|||
assertArrayEquals("The thierd row is not correct", expected[2], result[2], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void convertsArrayToString_SingleNumber() { |
|||
double[][] matrix = { { 1.0 } }; |
|||
String expected = "1.0 \n\n"; |
|||
|
|||
String result = util.convertsArrayToStringInOrderToDisplayIt(matrix); |
|||
|
|||
assertEquals("The Strings do not Match", expected, result); |
|||
} |
|||
|
|||
@Test |
|||
public void convertsArrayToString_FourNumbersInARow() { |
|||
double[][] matrix = { { 1.0, 2.0, 3.0, 4.0 } }; |
|||
String expected = "1.0 2.0 3.0 4.0 \n\n"; |
|||
|
|||
String result = util.convertsArrayToStringInOrderToDisplayIt(matrix); |
|||
|
|||
assertEquals("The Strings do not Match", expected, result); |
|||
} |
|||
|
|||
@Test |
|||
public void convertsArrayToString_FourNumbersInTwoRows() { |
|||
double[][] matrix = { { 1.0, 2.0 }, { 3.0, 4.0 } }; |
|||
String expected = "1.0 2.0 \n\n3.0 4.0 \n\n"; |
|||
|
|||
String result = util.convertsArrayToStringInOrderToDisplayIt(matrix); |
|||
|
|||
assertEquals("The Strings do not Match", expected, result); |
|||
} |
|||
} |
@ -0,0 +1,109 @@ |
|||
package com.ugsbo.matrixcalc; |
|||
|
|||
import static org.junit.Assert.assertArrayEquals; |
|||
import static org.junit.Assert.assertFalse; |
|||
import static org.junit.Assert.assertTrue; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
|
|||
/** |
|||
* Testet die Matrix Multiplication funkionalität |
|||
*/ |
|||
public class MatrixMultiplicationTest { |
|||
|
|||
private MatrixCalcMath matrixMath; |
|||
|
|||
@Before |
|||
public void setup() { |
|||
matrixMath = new MatrixCalcMath(); |
|||
} |
|||
|
|||
@Test |
|||
public void matrixAIsLinkedToMatrixBSouldBeTrue() { |
|||
double[][] matrixA = new double[1][2]; |
|||
double[][] matrixB = new double[2][1]; |
|||
|
|||
boolean result = matrixMath.checkIfMatriciesAreLinked(matrixA, matrixB); |
|||
|
|||
assertTrue("Matrix A is Linked to B but it is not detected that way", result); |
|||
} |
|||
|
|||
@Test |
|||
public void matrixAAndMatrixBAreNullSouldReturnFalse() { |
|||
double[][] matrixA = null; |
|||
double[][] matrixB = null; |
|||
|
|||
boolean result = matrixMath.checkIfMatriciesAreLinked(matrixA, matrixB); |
|||
|
|||
assertFalse("Matrix A and B are null but detected as Linked", result); |
|||
} |
|||
|
|||
@Test |
|||
public void matrixAAndMatrixBAreNotLinkedSouldReturnFalse() { |
|||
double[][] matrixA = new double[1][1]; |
|||
double[][] matrixB = new double[2][1]; |
|||
|
|||
boolean result = matrixMath.checkIfMatriciesAreLinked(matrixA, matrixB); |
|||
|
|||
assertFalse("Matrix A and B are not Linked but detected as Linked", result); |
|||
} |
|||
|
|||
@Test |
|||
public void multiplyTwoMatriciesWithSameDimensionsAndSameContent() { |
|||
double[][] matrixA = { { 1.0, 1.0 }, { 1.0, 1.0 } }; |
|||
double[][] matrixB = { { 1.0, 1.0 }, { 1.0, 1.0 } }; |
|||
double[][] matrixC = { { 2.0, 2.0 }, { 2.0, 2.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixMultiplication(matrixA, matrixB); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void multiplyTowMatriciesWithDiffrentDimensions() { |
|||
// A(2,3) B(3,2) => C(2,2) |
|||
double[][] matrixA = { { 1.0, 1.0, 1.0 }, { 1.0, 1.0, 1.0 } }; |
|||
double[][] matrixB = { { 1.0, 1.0 }, { 1.0, 1.0 }, { 1.0, 1.0 } }; |
|||
double[][] matrixC = { { 3.0, 3.0 }, { 3.0, 3.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixMultiplication(matrixA, matrixB); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void multiplyTowMatriciesWithDiffrentDimensionsAndDiffentContent() { |
|||
// A(2,3) B(3,2) => C(2,2) |
|||
double[][] matrixA = { { 1.0, 2.0, 3.0 }, { 4.0, 5.0, 6.0 } }; |
|||
double[][] matrixB = { { 7.0, 8.0 }, { 9.0, 10.0 }, { 11.0, 12.0 } }; |
|||
double[][] matrixC = { { 58.0, 64.0 }, { 139.0, 154.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixMultiplication(matrixA, matrixB); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
|
|||
public void tryToMultiplyTowEmptyMatricies() { |
|||
// A(0,0) B(0,0) => IllegalArgumentException |
|||
double[][] matrixA = new double[0][0]; |
|||
double[][] matrixB = new double[0][0]; |
|||
|
|||
matrixMath.matrixMultiplication(matrixA, matrixB); |
|||
} |
|||
|
|||
@Test(expected = IllegalArgumentException.class) |
|||
|
|||
public void tryToMultiplyTowNullObjects() { |
|||
// null null => IllegalArgumentException |
|||
double[][] matrixA = null; |
|||
double[][] matrixB = null; |
|||
|
|||
matrixMath.matrixMultiplication(matrixA, matrixB); |
|||
} |
|||
} |
@ -0,0 +1,57 @@ |
|||
package com.ugsbo.matrixcalc; |
|||
|
|||
import static org.junit.Assert.assertArrayEquals; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
|
|||
/** |
|||
* Tests the funktionality to Transpose a Matix |
|||
*/ |
|||
public class MatrixTransposeTest { |
|||
|
|||
private MatrixCalcMath matrixMath; |
|||
|
|||
@Before |
|||
public void setup() { |
|||
matrixMath = new MatrixCalcMath(); |
|||
} |
|||
|
|||
@Test |
|||
public void TransformQuadraticMatrixA_ResultsInQuadraticMatrixC() { |
|||
// A(2,2) => C(2,2) |
|||
double[][] matrixA = { { 1.0, 2.0 }, { 3.0, 4.0 } }; |
|||
double[][] matrixC = { { 1.0, 3.0 }, { 2.0, 4.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixTransponation(matrixA); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void Transform2by3MatrixA_ResultsIn3by2MatrixC() { |
|||
// A(2,3) => C(3,2) |
|||
double[][] matrixA = { { 1.0, 2.0, 3.0 }, { 4.0, 5.0, 6.0 } }; |
|||
double[][] matrixC = { { 1.0, 4.0 }, { 2.0, 5.0 }, { 3.0, 6.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixTransponation(matrixA); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
assertArrayEquals("The third row is not correct", matrixC[2], result[2], 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void Transform1by3MatrixA_ResultsIn3by1MatrixC() { |
|||
// A(1,3) => C(1,3) |
|||
double[][] matrixA = { { 1.0, 2.0, 3.0 } }; |
|||
double[][] matrixC = { { 1.0 }, { 2.0 }, { 3.0 } }; |
|||
|
|||
double[][] result = matrixMath.matrixTransponation(matrixA); |
|||
|
|||
assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1); |
|||
assertArrayEquals("The second row is not correct", matrixC[1], result[1], 0.1); |
|||
assertArrayEquals("The third row is not correct", matrixC[2], result[2], 0.1); |
|||
} |
|||
} |
@ -0,0 +1,63 @@ |
|||
package com.ugsbo.notenSpeicher; |
|||
|
|||
import static org.junit.Assert.*; |
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
import ugsbo.com.notenSpeicher.NotenKette; |
|||
|
|||
public class Test_NotenChain { |
|||
|
|||
public NotenKette Workingobjekt; |
|||
|
|||
@Before |
|||
public void setUp() throws Exception { |
|||
Workingobjekt = new NotenKette("first", 2); |
|||
} |
|||
|
|||
@Test |
|||
public void hinzufügen() { |
|||
String eingabeFach = "Mathe"; |
|||
int eingabeNote = 2; |
|||
|
|||
double erwartet = 2; |
|||
double ergebnis; |
|||
|
|||
Workingobjekt.add(eingabeFach, eingabeNote); |
|||
ergebnis = Workingobjekt.durchschnitt(); |
|||
|
|||
assertEquals(erwartet, ergebnis, 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void hinzufügenMehrAlsEinmal() { |
|||
String eingabeFach = "Mathe"; |
|||
int eingabeNote = 2; |
|||
double ergebnis; |
|||
double erwartet = 2; |
|||
|
|||
Workingobjekt.add(eingabeFach, eingabeNote); |
|||
Workingobjekt.add(eingabeFach, eingabeNote); |
|||
Workingobjekt.add(eingabeFach, eingabeNote); |
|||
|
|||
ergebnis = Workingobjekt.durchschnitt(); |
|||
|
|||
assertEquals(erwartet, ergebnis, 0.1); |
|||
} |
|||
|
|||
@Test |
|||
public void hinzufügenistNull() { |
|||
String eingabeFach = "Mathe"; |
|||
int eingabeNote = 2; |
|||
int eingabeNotezwei = 0; |
|||
double ergebnis; |
|||
double erwartet = 2; |
|||
|
|||
Workingobjekt.add(eingabeFach, eingabeNote); |
|||
Workingobjekt.add(eingabeFach, eingabeNotezwei); |
|||
|
|||
ergebnis = Workingobjekt.durchschnitt(); |
|||
|
|||
assertEquals(erwartet, ergebnis, 0.1); |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue