Compare commits
	
		
			2 Commits
		
	
	
		
			998d8aefd7
			...
			d8bd33e6d1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| d8bd33e6d1 | |||
| 3c28114bd5 | 
@@ -9,13 +9,13 @@ public class EinkommenInfo {
 | 
			
		||||
        GebietsListe gebietsListe = new GebietsListe(gebiet);
 | 
			
		||||
 | 
			
		||||
        System.out.println(gebietsListe.getAnzahlGesamt() + " Gebiete wurden eingelesen.");
 | 
			
		||||
        System.out.println(gebietsListe.getAnzahlUnvollstaendig() + " davon haben unvollständige Angaben.\n");
 | 
			
		||||
        System.out.println(gebietsListe.getAnzahlUnvollständig() + " davon haben unvollständige Angaben.\n");
 | 
			
		||||
 | 
			
		||||
        System.out.println("Gebiet mit dem geringsten Durchschnittseinkommen:");
 | 
			
		||||
        System.out.println(gebietsListe.getGebietMinDurchschnittEinkommen());
 | 
			
		||||
        System.out.println(gebietsListe.getGebietMinDurchschnittsEinkommen());
 | 
			
		||||
 | 
			
		||||
        System.out.println("Gebiet mit der größten Einwohernzahl:");
 | 
			
		||||
        System.out.println(gebietsListe.getGebietMaxEinwohner());
 | 
			
		||||
        System.out.println(gebietsListe.getGebietMaxAnzahlEinwohner());
 | 
			
		||||
 | 
			
		||||
        Scanner sc = new Scanner(System.in);
 | 
			
		||||
        while (true) {
 | 
			
		||||
@@ -24,7 +24,7 @@ public class EinkommenInfo {
 | 
			
		||||
            if (input.isEmpty()) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            List<Gebiet> foundAreas = gebietsListe.getGebietNachNamen(input);
 | 
			
		||||
            List<Gebiet> foundAreas = gebietsListe.getGebieteNachNamen(input);
 | 
			
		||||
            for (Gebiet area : foundAreas) {
 | 
			
		||||
                System.out.println(area);
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,21 +1,21 @@
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class GebietsListe {
 | 
			
		||||
public class GebietsListe implements GebietsListeInterface{
 | 
			
		||||
    private List<Gebiet> gebiete = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    public GebietsListe(List<Gebiet> gebiete) {
 | 
			
		||||
        this.gebiete = gebiete;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Gebiet getGebietMinDurchschnittEinkommen() {
 | 
			
		||||
    public Gebiet getGebietMinDurchschnittsEinkommen() {
 | 
			
		||||
        return gebiete.stream()
 | 
			
		||||
                .filter(g -> g.getDurchschnittsEinkommen() != -1)
 | 
			
		||||
                .min((g1, g2) -> g1.getDurchschnittsEinkommen() - g2.getDurchschnittsEinkommen())
 | 
			
		||||
                .get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Gebiet getGebietMaxEinwohner() {
 | 
			
		||||
    public Gebiet getGebietMaxAnzahlEinwohner() {
 | 
			
		||||
        return gebiete.stream()
 | 
			
		||||
                .filter(g -> g.getDurchschnittsEinkommen() != -1)
 | 
			
		||||
                .max((g1, g2) -> g1.getAnzahlEinwohner() - g2.getAnzahlEinwohner())
 | 
			
		||||
@@ -26,13 +26,13 @@ public class GebietsListe {
 | 
			
		||||
        return gebiete.size();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getAnzahlUnvollstaendig() {
 | 
			
		||||
    public int getAnzahlUnvollständig() {
 | 
			
		||||
        return (int) gebiete.stream()
 | 
			
		||||
                .filter(g -> g.getDurchschnittsEinkommen() == -1 || g.getGesamtEinkommen() == -1)
 | 
			
		||||
                .count();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<Gebiet> getGebietNachNamen(String namensanfang) {
 | 
			
		||||
    public List<Gebiet> getGebieteNachNamen(String namensanfang) {
 | 
			
		||||
        return gebiete.stream()
 | 
			
		||||
                .filter(g -> g.getName().startsWith(namensanfang))
 | 
			
		||||
                .toList();
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								src/GebietsListeInterface.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/GebietsListeInterface.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public interface GebietsListeInterface {
 | 
			
		||||
    Gebiet getGebietMinDurchschnittsEinkommen();
 | 
			
		||||
    Gebiet getGebietMaxAnzahlEinwohner();
 | 
			
		||||
    int getAnzahlGesamt();
 | 
			
		||||
    int getAnzahlUnvollständig();
 | 
			
		||||
    List<Gebiet> getGebieteNachNamen(String namensanfang);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user