Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/GebietsDatei.java
This commit is contained in:
Felix Wöstemeyer 2022-12-09 13:53:13 +01:00
commit 1b6ecf5886
9 changed files with 284 additions and 8 deletions

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -6,8 +6,57 @@
* abgeleitete Eigenschaft und wird dementsprechend in der Methode 'getAnzahlEinwohner'
* berechnet.
*
* @author Gubitz, Wöstemeyer, Pfannenstiel, Maier, Vigier :D
* @author Vigier
*/
public class Gebiet {
//gepushter kommentar
public class Gebiet implements GebietInterface {
private int jahr;
private int schlüssel;
private String name;
private long gesamtEinkommen;
private int durchschnittsEinkommen;
public Gebiet(int jahr, int schlüssel, String name, long gesamtEinkommen, int durchschnittsEinkommen) {
this.jahr = jahr;
this.schlüssel = schlüssel;
this.name = name;
this.gesamtEinkommen = gesamtEinkommen;
this.durchschnittsEinkommen = durchschnittsEinkommen;
}
@Override
public int getjahr() {
return jahr;
}
@Override
public int getSchüssel() {
return schlüssel;
}
@Override
public String getName() {
return name;
}
@Override
public long getGesamtEinkommen() {
if(gesamtEinkommen == 0){
return -1;
}
return gesamtEinkommen;
}
@Override
public int getDurchschnittsEinkommen() {
if(getDurchschnittsEinkommen() == 0){
return -1;
}
return durchschnittsEinkommen;
}
@Override
public int getAnzahlEinwohner() {
return (int) (gesamtEinkommen / durchschnittsEinkommen);
}
}

8
src/GebietInterface.java Normal file
View File

@ -0,0 +1,8 @@
public interface GebietInterface {
int getjahr();
int getSchüssel();
String getName();
long getGesamtEinkommen();
int getDurchschnittsEinkommen();
int getAnzahlEinwohner();
}

View File

@ -1,3 +1,5 @@
import java.util.List;
/**
* Die Klasse 'GebietsListe' enthält als Attribut eine Liste von Gebiet-Objekten. Darauf
* aufbauend wird eine Reihe von Algorithmen bereitgestellt, die die Liste der Gebiete
@ -13,5 +15,12 @@
*
* @author Gubitz, Wöstemeyer, Pfannenstiel, Maier, Vigier :D
*/
public class GebietListe {
public class GebietListe implements ListenInterface
{
private List<Gebiet> gebiete;
public GebietListe(List<Gebiet> gebiete)
{
this.gebiete = gebiete;
}
}

32
src/GebietMock.java Normal file
View File

@ -0,0 +1,32 @@
public class GebietMock implements GebietInterface{
@Override
public int getjahr() {
return 0;
}
@Override
public int getSchüssel() {
return 0;
}
@Override
public String getName() {
return null;
}
@Override
public long getGesamtEinkommen() {
return 0;
}
@Override
public int getDurchschnittsEinkommen() {
return 0;
}
@Override
public int getAnzahlEinwohner() {
return 0;
}
}

View File

@ -1,10 +1,42 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
/**
* Die Klasse 'Gebietsdatei' hat die Aufgabe, die Datei 'Einkommen.csv' einzulesen, zu
* interpretieren, als Gebiet-Objekte zu speichern und diese in Form einer Liste zur Verfügung
* zu stellen.
*
* @author Gubitz, Wöstemeyer, Pfannenstiel, Maier, M. Vigier :D
* @author Gubitz, Wöstemeyer, Pfannenstiel, Maier, Vigier
*/
public class GebietsDatei {
//wg //er kam, er sah und siegtedfg
public class GebietsDatei implements GebietsQuelle{
private ArrayList<Gebiet> gebiete = new ArrayList<>();
public void GebietsDatei (String dateiname){
Path pfad = Paths.get(dateiname);
try {
List<String> zeilen = Files.readAllLines(pfad);
for(String zeile : zeilen) {
String[] teile = zeile.split(";");
int jahr = Integer.parseInt(teile[0]);
int schlüssel = Integer.parseInt(teile[1]);
String region = teile[2];
int einkommenProHaushalt = Integer.parseInt(teile[3]);
int einkommenjeEinwohner = Integer.parseInt(teile[4]);
gebiete.add(new Gebiet(jahr, schlüssel, region, einkommenProHaushalt, einkommenjeEinwohner));
}
} catch (IOException e) {
e.printStackTrace();
}
}
public List<Gebiet> getGebiete() {
return gebiete;
}
}

6
src/GebietsQuelle.java Normal file
View File

@ -0,0 +1,6 @@
import java.util.ArrayList;
import java.util.List;
public interface GebietsQuelle {
List<Gebiet> getGebiete();
}

3
src/ListenInterface.java Normal file
View File

@ -0,0 +1,3 @@
public interface ListenInterface
{
}

13
src/MockGebietsDatei.java Normal file
View File

@ -0,0 +1,13 @@
import java.util.*;
public class MockGebietsDatei implements GebietsQuelle {
private ArrayList<Gebiet> gebiete = new ArrayList<>();
public void GebietsDatei (String dateiname){
}
public List<Gebiet> getGebiete() {
return gebiete;
}
}