M
Miss. Michelle Heigardt
Hallo, I have a simple question where I want to comment my Java code.
I have rule below
//I want to put comment in here to describe the boolean
//test the method does.
private int booleanRule(int i1, int i2, int i3, int i4, int i5)
throws Exception
{
if (!((i1==0) | (i1==1))) throw new Exception("Illegal i1");
if (!((i2==0) | (i2==1))) throw new Exception("Illegal i2");
if (!((i3==0) | (i3==1))) throw new Exception("Illegal i3");
if (!((i4==0) | (i4==1))) throw new Exception("Illegal i4");
if (!((i5==0) | (i5==1))) throw new Exception("Illegal i5");
if ((i1+i2+i3+i4+i5)>1) throw new Exception("Allowed only 1 i
set");
return (i1+i2+i3+i4+i5);
}
For the comments in my code what can I describe this as? (I now it is
not a NAND or a NOR or an AND or an OR or a BIT).
What it does is that if all i1, i2, i3, i4, and i5 is 0, it returns 0.
If any of i1, i2, i3, i4, i5 is 1 it returns 1.
If more than 1 i is set, it errors.
If i is anything other than 1 or 0 it errors.
Thank you.
Michelle
I have rule below
//I want to put comment in here to describe the boolean
//test the method does.
private int booleanRule(int i1, int i2, int i3, int i4, int i5)
throws Exception
{
if (!((i1==0) | (i1==1))) throw new Exception("Illegal i1");
if (!((i2==0) | (i2==1))) throw new Exception("Illegal i2");
if (!((i3==0) | (i3==1))) throw new Exception("Illegal i3");
if (!((i4==0) | (i4==1))) throw new Exception("Illegal i4");
if (!((i5==0) | (i5==1))) throw new Exception("Illegal i5");
if ((i1+i2+i3+i4+i5)>1) throw new Exception("Allowed only 1 i
set");
return (i1+i2+i3+i4+i5);
}
For the comments in my code what can I describe this as? (I now it is
not a NAND or a NOR or an AND or an OR or a BIT).
What it does is that if all i1, i2, i3, i4, and i5 is 0, it returns 0.
If any of i1, i2, i3, i4, i5 is 1 it returns 1.
If more than 1 i is set, it errors.
If i is anything other than 1 or 0 it errors.
Thank you.
Michelle