Compare commits

9 Commits

Author SHA1 Message Date
0643732d08 main 2022-12-06 14:45:42 +01:00
7ca888121d fixed Constructor 2022-12-06 14:45:25 +01:00
da5bcc93bf toString 2022-12-06 14:44:53 +01:00
daf0ec541d getAnzahlEinwohner implementiert 2022-12-06 14:22:27 +01:00
268f4eee43 renamed Main to EinkommenInfo 2022-12-06 14:01:59 +01:00
a2bd838467 Gebiet 2022-12-06 13:54:40 +01:00
78dfa848fa Merge pull request 'Add: GebietsDatei fixed #6' (#8) from readfile into master
Reviewed-on: #8
2022-12-02 15:13:55 +01:00
pbs2h21asc
2562126caa Gebietliste 2022-12-02 15:10:14 +01:00
9c6592fbff GebietsListe Methoden 2022-12-02 15:07:08 +01:00
5 changed files with 83 additions and 8 deletions

10
.idea/runConfigurations.xml generated Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

29
src/EinkommenInfo.java Normal file
View File

@@ -0,0 +1,29 @@
import java.util.List;
import java.util.Scanner;
public class EinkommenInfo {
public static void main(String[] args) {
System.out.println("Übersicht über Bevölkerungszahl und Einkommen in Deutschland");
GebietsDatei datei = new GebietsDatei("Einkommen.csv");
List<Gebiet> gebiet = datei.getGebiete();
GebietsListe gebietsListe = new GebietsListe(gebiet);
System.out.println(gebiet.size() + " Gebiete wurden eingelesen.");
System.out.println(gebietsListe.getAnzahlUnvollstaendig() + " davon haben unvollständige Angaben.");
System.out.println();
System.out.println("Gebiet mit dem geringsten Durchschnittseinkommen:");
System.out.println(gebietsListe.getGebietMinDurchschnittEinkommen());
Scanner sc = new Scanner(System.in);
while(true){
System.out.print("Name des Gebietes: ");
String input = sc.nextLine();
if(input.isEmpty()){
break;
}
List<Gebiet> foundAreas = gebietsListe.getGebietNachNamen(input);
for (Gebiet area : foundAreas) {
System.out.println(area);
}
System.out.println(foundAreas.size() + " Gebiete wurden gefunden.");
}
}
}

View File

@@ -1,4 +1,3 @@
public class Gebiet implements GebietInterface{
private int jahr;
private int schlüssel;
@@ -31,16 +30,27 @@ public class Gebiet implements GebietInterface{
@Override
public long getGesamtEinkommen() {
if(gesamtEinkommen <= 0){
return -1;
}
return gesamtEinkommen;
}
@Override
public int getDurchschnittsEinkommen() {
if(durchschnittsEinkommen <= 0){
return -1;
}
return durchschnittsEinkommen;
}
@Override
public int getAnzahlEinwohner() {
return 0;
return (int)(gesamtEinkommen / durchschnittsEinkommen);
}
@Override
public String toString() {
return getName() + "\n" + getAnzahlEinwohner() + " Einwohner\n" + getDurchschnittsEinkommen() + " Euro / Einwohner\n";
}
}

View File

@@ -1,3 +1,34 @@
public class GebietsListe {
import java.util.ArrayList;
import java.util.List;
public class GebietsListe {
private List<GebietMock> gebietListe = new ArrayList<>();
public GebietsListe(List<Gebiet> gebiete){
this.gebietListe = gebietListe;
}
public Gebiet getGebietMinDurchschnittEinkommen(){
return null;
}
public Gebiet getGebietMaxEinwohner(){
return null;
}
public int getAnzahlGesamt(){
return 0;
}
public int getAnzahlUnvollstaendig(){
return 0;
}
public List<Gebiet> getGebietNachNamen(String namensanfang){
return null;
}
}

View File

@@ -1,5 +0,0 @@
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}