Question
So theres a line in my code that wont work for when i create a set method.. this is the constructor public DataEntry(int r, int
So theres a line in my code that wont work for when i create a set method.. this is the constructor
public DataEntry(int r, int c, double val) {
setRow(r);
setColumn(c);
value = val;
}
but when i run the code, the line that doesnt work says that the constructor DataEntry() is undefined, HELP!
/**
* 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) {
boolean isNew = true;
for (DataEntry dataEntry : data) {
if (dataEntry.getColumn() == column && dataEntry.getRow() == row) {
dataEntry.setValue(val);
isNew = false;
}
}
if (isNew) {
line wont work... DataEntry newData = new DataEntry();
newData.setColumn(column);
newData.setRow(row);
newData.setValue(val);
data.add(newData);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started