initial commit

This commit is contained in:
Marc Koch 2020-04-12 14:39:14 +02:00
commit ff43a6eec8
16 changed files with 167 additions and 0 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

1
.idea/description.html Normal file
View File

@ -0,0 +1 @@
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>

6
.idea/encodings.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>

12
.idea/misc.xml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectKey">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" default="true" project-jdk-name="13" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/frachtfluege.iml" filepath="$PROJECT_DIR$/frachtfluege.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,3 @@
<template>
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
</template>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# frachtflüge
![Aufgabe](img/frachtfluege_Bild.png)

12
frachtfluege.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

BIN
img/frachtfluege_Bild.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,9 @@
package gfn.marc;
public class Frachtfluege {
public static void main(String[] args) {
String[][] route = Routen.getRoute("A", "B");
}
}

90
src/gfn/marc/Routen.java Normal file
View File

@ -0,0 +1,90 @@
package gfn.marc;
// Hilfsklasse zur Simulation der Aufgabenstellung
import java.util.*;
import static java.util.Map.entry;
public class Routen {
static Ort a = new Ort("A", 1600, 5.6);
static Ort b = new Ort("B", 1800, 5.2);
static Ort c = new Ort("C", 1300, 5.5);
static Ort d = new Ort("D", 1450, 4.9);
static Ort e = new Ort("E", 1400, 5.1);
static {
a.setKnoten(b, c, d);
b.setKnoten(a, c, e);
c.setKnoten(a, b);
d.setKnoten(a, e);
e.setKnoten(b, d);
a.berechneRouten();
b.berechneRouten();
c.berechneRouten();
d.berechneRouten();
e.berechneRouten();
}
public static String[][] getRoute(String SB, String SE) {
for (Ort ort : Ort.orte) {
if (ort.id.matches(SB)) {
return ort.routen.get(SB.concat(SE));
}
}
return null;
}
}
class Ort {
static ArrayList<Ort> orte = new ArrayList<>();
String id;
int frachtkapazitaet;
double frachtkosten; // EUR/kg
ArrayList<Ort> knoten;
HashMap<String, Ort> knotenMap;
HashMap<String, String[][]> routen;
public Ort(String id, int frachtkapazitaet, double frachtkosten) {
this.id = id;
this.frachtkapazitaet = frachtkapazitaet;
this.frachtkosten = frachtkosten;
Ort.orte.add(this);
}
public void setKnoten(Ort... knotenArray) {
ArrayList<Ort> knoten = new ArrayList<>();
HashMap<String, Ort> knotenMap = new HashMap<>();
for (Ort k : knotenArray) {
knoten.add(k);
knotenMap.put(k.id, k);
}
this.knoten = knoten;
this.knotenMap = knotenMap;
}
void berechneRouten() {
HashMap<String, String[][]> routen = new HashMap<>();
for (Ort o : orte) {
if (!this.id.equals(o.id)) {
routen.put(this.id.concat(o.id), new String[this.knoten.size()][orte.size()]);
for (int i = 0; i < routen.get(this.id.concat(o.id)).length; i++) {
routen.get(this.id.concat(o.id))[i][0] = this.id;
for (int j = 1; j < routen.get(this.id.concat(o.id))[i].length; j++) {
if (routen.get(this.id.concat(o.id))[i][j].isBlank()) {
// TODO: Hier weitermachen!
}
}
}
}
}
}
this.routen = routen;
}
}