s*******n 发帖数: 97 | 1 问题3:
Design a excel worksheet, that support literal, e.g., “500”, also
expressions, e.g., A4=“A1+A5”, A4=f(A1,A2,A6)..etc
没思路,any ideas?
原帖在这里: http://www.mitbbs.com/article_t/JobHunting/31339967.html | c*****n 发帖数: 96 | 2 Use factory pattern:
//Define a abstract class Cell which the application (Excel) will
//process.
public abstract class Cell {
....
public TValue getValue();
}
// Define concrete cell class
public class LiteralCell : Cell { // '500'
public override TValue getValue() { ... }
}
public class ExpressionCell :Cell { // 'A5 + A10'
public override TValue getValue() { ....}
}
public class FunctionCell : Cell { // 'f(A1, A2, A5)'
public override TValue getValue() { ....}
}
// define a cell factory
public class CellFactory {
// constructor
public CellFactory( Configuration conf) {
// conf is a extension point which can be use to add
// new concrete cell class in the system.
....
}
public Cell CreateCell(string userInput, Context context){
// parse user input string to create concrete cell object
accordingly.
}
} | s*******n 发帖数: 97 | |
|