public class Client {
private ArrayList<DataEntry> data;
private String title;
/**
* create a new worksheet with given title
* @param title
*/
public Worksheet(String title) {
data = new ArrayList<DataEntry>();
this.title = title;
}
/**
* @return a shallow copy of the data
*/
public ArrayList<DataEntry> getData() {
return data;
}
/**
*
* @return title of the worksheet
*/
public String getTitle() {
return title;
}
/**
*
* @param row
* @param column
* @return value of item at given row and column (if any), null otherwise
*/
public Double get(int row, int column) {
return null; // to be completed
}
/**
* set the value of DataEntry object at given row and column to given value
*
* if a DataEntry object for given row and column already exists, overwrite the current value
* if a DataEntry object for given row and column doesn't exist, add a new DataEntry object
* with given row, column, value to the list.
* @param row
* @param column
* @param val
*/
public void set(int row, int column, double val) {
//to be completed
}
/**
*
* @param row
* @param column
* @return index of DataEntry object in list data with given row and column
* return -1 if no such DataEntry object found
*/
public int indexOf(int row, int column) {
this.get(row, column);
return 0; //to be completed
}
}
I was given this code to practice for a future exam. I have no clue how to do any of the tasks. Any help understanding what to do would be greatly appreciated!!! Thanks!!
P.S. I also have another java class called DataEntry which contains a bunch of setters and getters with headers as public
e.g.
public void setRow(int r) {
row = Math.max(0, r);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…