initial commit
This commit is contained in:
commit
3b63ef540b
|
|
@ -0,0 +1,3 @@
|
|||
# Ladungsliste
|
||||

|
||||

|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 99 KiB |
|
|
@ -0,0 +1,85 @@
|
|||
package gfn.marc;
|
||||
|
||||
public class Ladungsliste {
|
||||
|
||||
static int[][] leereLadungsliste = generiereLeereLadungsliste(150);
|
||||
static double nutzlast_kg = 7500.0;
|
||||
static int maxAnzahl_Palette = 17;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
int[][] ladungsliste = erstelleLadungsliste(leereLadungsliste, nutzlast_kg, maxAnzahl_Palette);
|
||||
|
||||
// Ausgabe der LKW-Beladung
|
||||
if (ladungsliste.length > 0) {
|
||||
System.out.println("Gewicht der Pallette in kg | LKW-Nr. | Palette-Nr.");
|
||||
System.out.println("------------------------------------------------------");
|
||||
for (int[] zeile : ladungsliste) {
|
||||
System.out.println(" " + zeile[0] + " " + zeile[1] +
|
||||
" " + zeile[2]);
|
||||
}
|
||||
} else System.err.println("Keine Ladungsliste vorhanden!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Methode zur erstellung vollständiger Ladelisten (wie in Aufgabe gefordert)
|
||||
static int[][] erstelleLadungsliste(int[][] ladungsliste, double nutzlast_kg, int maxAnzahl_Palette) {
|
||||
|
||||
int lkwNr = 1;
|
||||
int[] zaehler = new int[ladungsliste.length];
|
||||
int[][] neueLadungsliste = new int[ladungsliste.length][3];
|
||||
|
||||
// Gewicht der Ladung und Anzahl der Palletten aufaddieren, bis einer der Maximalwerte überschritten wird
|
||||
// Anzahl in zaehler-Array festhalten
|
||||
int gewichtLadung = 0;
|
||||
int i = 0;
|
||||
int anzahlPalletten = 0;
|
||||
for (int[] zeile : ladungsliste) {
|
||||
anzahlPalletten++;
|
||||
gewichtLadung += zeile[0];
|
||||
if (anzahlPalletten > maxAnzahl_Palette || gewichtLadung > nutzlast_kg) {
|
||||
i++;
|
||||
anzahlPalletten = 0;
|
||||
gewichtLadung = 0;
|
||||
} else zaehler[i]++;
|
||||
}
|
||||
|
||||
// neue Ladeliste füllen
|
||||
// LKW-Nr hochzählen, wenn Wert des Eintrags im zaehler-Array erreicht
|
||||
int k = 0;
|
||||
for (int j = 0; j < ladungsliste.length; j++) {
|
||||
neueLadungsliste[j][0] = ladungsliste[j][0];
|
||||
if (zaehler[k] > 1 && lkwNr < 11) {
|
||||
neueLadungsliste[j][1] = lkwNr;
|
||||
zaehler[k]--;
|
||||
} else if (lkwNr < 11){
|
||||
neueLadungsliste[j][1] = lkwNr;
|
||||
lkwNr++;
|
||||
k++;
|
||||
}
|
||||
neueLadungsliste[j][2] = ladungsliste[j][2];
|
||||
|
||||
}
|
||||
|
||||
// neue Ladeliste zurückgeben
|
||||
return neueLadungsliste;
|
||||
}
|
||||
|
||||
|
||||
// Hilfs-Methode zur Generierung zufällige Ladelisten
|
||||
static int[][] generiereLeereLadungsliste(int anzahlPaletten) {
|
||||
int[][] leereLadungsListe = new int[anzahlPaletten][3];
|
||||
|
||||
int paletteNrPraefix = 276100;
|
||||
for (int[] zeile : leereLadungsListe) {
|
||||
zeile[0] = (int) (Math.random() * 4 + 5) * 100;
|
||||
zeile[1] = 0;
|
||||
zeile[2] = paletteNrPraefix++;
|
||||
}
|
||||
|
||||
return leereLadungsListe;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue