A spreadsheet is a grid with 26 columns (labeled from
'A'to'Z') and a given number ofrows. Each cell in the spreadsheet can hold an integer value between 0 and 105.Implement the
Spreadsheetclass:
Spreadsheet(int rows)Initializes a spreadsheet with 26 columns (labeled'A'to'Z') and the specified number of rows. All cells are initially set to 0.void setCell(String cell, int value)Sets the value of the specifiedcell. The cell reference is provided in the format"AX"(e.g.,"A1","B10"), where the letter represents the column (from'A'to'Z') and the number represents a 1-indexed row.void resetCell(String cell)Resets the specified cell to 0.int getValue(String formula)Evaluates a formula of the form"=X+Y", whereXandYare either cell references or non-negative integers, and returns the computed sum.Note: If
getValuereferences a cell that has not been explicitly set usingsetCell, its value is considered 0.
1 |
|