// CS U213 Spring 2009 // Assignment 3 // Problem 3.3 // October 2, 2008 /* +------------+ | Cell |<---------------------+-+ +------------+ | | | int row | | | | int col | | | | IData data |-+ | | +------------+ | | | | | | v | | +-------+ | | | IData | | | +-------+ | | / \ | | --- | | | | | ----------------------------- | | | | | | +------------+ +----------+ | | | Number | | Formula | | | +------------+ +----------+ | | | int number | | Cell op1 |---+ | +------------+ | Cell op2 |-----+ +-| IFun fun | | +----------+ v +------+ | IFun | +------+ / \ --- | ------------------------ | | | +------+ +---------+ +-------+ | Plus | | Minimum | | Times | +------+ +---------+ +-------+ */ // to represent a cell in a spreadsheet class Cell{ int row; int col; IData data; Cell(int row, int col, IData data){ this.row = row; this.col = col; this.data = data; } } // to represent data in one cell of an Excel spreadsheet interface IData{ } // to represent numerical data in one cell of a spreadsheet class Number{ int number; Number(int number){ this.number = number; } } // to represent a formula data in one cell of a spreadsheet class Formula{ Cell op1; Cell op2; IFun fun; Formula(Cell op1, Cell op2, IFun fun){ this.op1 = op1; this.op2 = op2; this.fun = fun; } } // to represent a function of two arguments interface IFun{ } // to represent an addition function of two arguments class Plus implements IFun{ } // to represent a function of two arguments that produces the minimum class Minimum implements IFun{ } // to represent a multiplication function of two arguments class Times implements IFun{ }