Test 004
1. A cost-map contains M*N cells, we have the cost rate for each individual cell.
2. The path is defined as a sequence of cells that connect to each other directly.
3. If two cells are in the same row or column, and there is no cell between them, these two cells are defined as directly connected.
4. The cost of a path is the summary of all the cells� costs involved.
lYou are required to find out a cheapest path from one specified cell to another.
lRequirement:
1. Based on the existing partial system (described below), design and implement your module to solve the problem.
2. Document the API of your module.
3. Draw the relevant UML diagrams for your design.
4. Finish the implementation using language of
Java 5. Document your consideration for the performance in your design, because this program may run on devices with limited memory and calculation capabilities.
lThe existing partial system
Map
M: intN: int
getCell(int row, int col): CellgetStartCell(): CellgetTargetCell(): Cell
M: is the row number of the map
N: is the column number of the map
getCell returns the Cell with row and column specified. The start index is 0.
getStartCell and GetTargetCell return the start and end cell of the problem.
Cell
row: intcol: int
getCost(): int
Trace
getTraceLength(): intgetCell(int n): CellgetCost(): int
getTraceLength returns how many cells are involved in this trace.
getCell returns the number n cell in this trace.
getCost returns the total cost of this trace.
[ February 10, 2004: Message edited by: frank yang ]