Just need a few pointers with the code below.
I have the below class to complete but I am stuck on the isAllValidDigits() method where i have to create a loop to check and return true if all the int values of the authorId array and the programId array are in the valid range of 0-9 inclusive, otherwise return false.
public class ISPN
{
private int[] authorId;
private int[] programId;
/**
* Creates a new instance of ISPN
*/
public ISPN(int[] anAuthorId, int[] aProgramId)
{
int[] authorId = anAuthorId;
int[] programId = aProgramId;
}
public boolean isValidLength()
{
// TODO
int numAuthor = authorId.length;
int numProgram = programId.length;
if((numAuthor + numProgram) == 6)
{
return true;
}
else
{
return false;
}
}
public boolean isAllValidDigits()
{
// TODO
for(int i = 0; i < authorId.length; i++)
for(int j = 0; j < programId.length; j++)
{
if((i >= 0)&&(i <= 9))
{
return true;
}
if((j >= 0)&&(j <= 9))
{
return true;
}
}
return false;
}
}