/** Table.java models a table of numbers.
 * @author Joel Adams, for Alice+Java.
 */

public class Table {
	public Table(int rows, int columns) {
		if (rows < 1 || columns < 1) {
			throw new IllegalArgumentException("SalesTable(): bad args");
		}
		myTable = new double[rows][columns];
		myRows = rows;
		myColumns = columns;
	}
	
	public int getRows() { return myRows; }
	public int getColumns() { return myColumns; }
	
	public double get(int r, int c) {
		return myTable[r][c];
	}

	public void set(int r, int c, double item) {
		myTable[r][c] = item;
	}
	
	public String toString() {
		String result = "";
		for (int r = 0; r < myTable.length; r++) {
			for (int c = 0; c < myTable[r].length; c++) {
				result += (myTable[r][c] + "\t");
			}
			result += "\n";
		}
//		for (double [] row : myTable) {
//			for (double item : row) {
//				result += (item + "\t");
//			}
//			result += "\n";
//		}
		return result;
	}

	private int myRows, myColumns;
	private double [][] myTable = null;
}
