diff --git a/Programmierung2/src/streams/Finanzanalyse/Finanzanalyse.java b/Programmierung2/src/streams/Finanzanalyse/Finanzanalyse.java index b9b441f..e951a5f 100644 --- a/Programmierung2/src/streams/Finanzanalyse/Finanzanalyse.java +++ b/Programmierung2/src/streams/Finanzanalyse/Finanzanalyse.java @@ -11,6 +11,18 @@ public class Finanzanalyse { public static void main(String[] args) throws FileNotFoundException { Finanzanalyse f = new Finanzanalyse(); f.addTran(); + + //Eine gefilterte Liste mit allen Überweisungen in einer bestimmten Währung. + f.getTran().stream() + .filter(w -> w.getCurrency().equalsIgnoreCase("EUR")) + .forEach(System.out::println); + + + //Gesamtsumme der Überweisungen in den jeweiligen Währungen. + long usdÜberwei = f.getTran().stream() + .filter(w -> w.getCurrency().equals("USD")) + .count(); + System.out.println(usdÜberwei); } private ArrayList tran = new ArrayList<>(); @@ -31,4 +43,10 @@ public class Finanzanalyse { scan.close(); } + + public ArrayList getTran() { + return tran; + } + + } diff --git a/Programmierung2/src/streams/Finanzanalyse/Transaction.java b/Programmierung2/src/streams/Finanzanalyse/Transaction.java index 534ed44..e4a66b2 100644 --- a/Programmierung2/src/streams/Finanzanalyse/Transaction.java +++ b/Programmierung2/src/streams/Finanzanalyse/Transaction.java @@ -2,13 +2,13 @@ package streams.Finanzanalyse; public class Transaction { - private String sender_name; - private String sender_account; - private String receiver_name; - private String receiver_account; - private double amount; - private String currency; - private String receiver_Country; + private String sender_name; //absenderName + private String sender_account; //absenderKonto + private String receiver_name; //empfaengerName + private String receiver_account; //empfaengerKonto + private double amount; //betrag + private String currency; //waehrung + private String receiver_Country; //empfaengerLand public Transaction(String sender_name, String sender_account, String receiver_name, String receiver_account, double amount, String currency, String receiver_Country) {