Question
public class Matrix { private int nRow, nCol; private double[] data; // must store as linear array unless 0 //getter for NRow - do not
public class Matrix
{
private int nRow, nCol;
private double[] data; // must store as linear array unless 0
//getter for NRow - do not modify
public int getNRow()
{
return nRow;
}
//getter for NCol - do not modify
public int getNCol()
{
return nCol;
}
/**
* set nRow to r if r is not negative, otherwise set nRow to 0
* @param r: value to be assigned to nRow
*/
public void setNRow(int r)
{
//to be completed
}
/**
* set nCol to c if c is not negative, otherwise set nCol to 0
* @param c: value to be assigned to nCol
*/
public void setNCol(int c)
{
//to be completed
}
/**
*
* @return true if both nRow and nCol are zero, false otherwise
*/
public boolean isEmpty()
{
return false; //to be completed
}
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