public class AssemblyLine { /** * entryCosts is the cost to enter a particular assembly line. */ static int[] entryCosts = { 3, 4, 2 }; /** * exitCosts is the cost to move the product off of each assembly line. */ static int[] exitCosts = { 1, 1, 4}; /** * nodeCosts is the cost to enter a particular work station * on the assembly line. Thus nodeCosts[ x][ y] is the cost * to enter the yth node on assembly line x. */ static int[][] nodeCosts = { { 3, 5, 2, 7, 2}, { 2, 3, 8, 4, 6}, { 4, 2, 6, 2, 3}}; /** * transferCosts in the addition cost to change assembly * lines. Each two-dimensional array is the costs to * transfer from nodes in that assembly line. Thus, * transferCosts[ x][ y][ z] is the cost to transfer from * node z on assembly line x to node z + 1 on assembly line y. */ static int[][][] transferCosts = { { { 0, 0, 0, 0, 0 }, // transfers from line 0 to line 0 { 2, 1, 3, 2, 0 }, // transfers from line 0 to line 1 { 1, 2, 3, 4, 0 }}, // transfers from line 0 to line 2 { { 2, 2, 1, 2, 0 }, // transfers from line 1 to line 0 { 0, 0, 0, 0, 0 }, // transfers from line 1 to line 1 { 1, 2, 1, 2, 0 }}, // transfers from line 1 to line 2 { { 1, 1, 3, 2, 0 }, // transfers from line 2 to line 0 { 2, 3, 3, 2, 0 }, // transfers from line 2 to line 1 { 0, 0, 0, 0, 0 }}};// transfers from line 2 to line 2 /** The fastest cost after exiting the factory. */ static int fastestCostStar = -1; /** The assembly line from which the fastest path exited the factory. */ static int fastestPathStar = -1; /** The fastest costs so far. */ static int[][] fastestCost = new int[ 3][ 5]; /** The path for the fastest costs so far. The first column should remain 0s. */ static int[][] fastestPath = new int[ 3][ 5]; /** * fastestWay calculates the fastest way through the factory, * putting the costs into the fastestCost array and the path * indicators into the path array. */ public static void fastestWay() { // TO DO } /** * printStations prints out the stations used, in decreasing order. */ public static void printStations() { // TO DO } /** * Prints out the contents of a two dimensional array. * @param array The two-d array to display. */ public static void print2dArray( int[][] array) { for( int index = 0; index < array.length; index++) { for( int jdex = 0; jdex < array[index].length; jdex++) { System.out.print( " " + array[index][jdex]); } System.out.println(); } } public static void main( String[] args) { System.out.println( "" + nodeCosts); print2dArray( nodeCosts); } }