Compare commits

...

2 Commits

Author SHA1 Message Date
DexterHK ebbe470ae6 test 2022-12-11 14:58:31 +01:00
Oliver Hummel 3c8c557262 Experimentelle Sortierung der Kontenliste 2022-11-29 14:07:07 +01:00
4 changed files with 23 additions and 8 deletions

View File

@ -1,11 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -2,6 +2,7 @@ package de.hs_mannheim.informatik.bank.domain;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
public class Bank implements Serializable {

View File

@ -3,7 +3,7 @@ package de.hs_mannheim.informatik.bank.domain;
import java.io.Serializable;
import java.util.ArrayList;
public class Konto implements Serializable {
public class Konto implements Serializable, Comparable {
private int nummer;
protected long stand = 0;
private String inhaber;
@ -23,7 +23,7 @@ public class Konto implements Serializable {
@Override
public String toString() {
return "Konto [nummer=" + nummer + ", inhaber=" + inhaber + "]";
return "Konto "+ stand + "[nummer=" + nummer + ", inhaber=" + inhaber + "]";
}
public String getInhaber() {
@ -73,4 +73,14 @@ public class Konto implements Serializable {
return saldo;
}
@Override
public int compareTo(Object other) {
Konto kOther = (Konto) other;
// return (int) (this.stand - kOther.stand);
return this.inhaber.compareTo(kOther.inhaber);
//m1.getRating() < m2.getRating() < 0;
//
}
}

View File

@ -1,6 +1,9 @@
package de.hs_mannheim.informatik.bank.facade;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.TreeSet;
import de.hs_mannheim.informatik.bank.domain.Bank;
import de.hs_mannheim.informatik.bank.domain.Girokonto;
@ -27,10 +30,15 @@ public class Banksystem {
public String[] getKontenliste() {
Collection<Konto> konten = bank.getKontenliste();
TreeSet<Konto> ts = new TreeSet<>(konten);
String[] liste = new String[konten.size()];
int i = 0;
for (Konto k : konten) {
for (Konto k : ts) {
liste[i++] = k.toString();
}