Please help. blue j test method
hi there. i am new to this forum and was wondering if anyone could help me
i have a test that i need to pass, but i am have no luck..
the test code is
Code:
public void testCuttingGrassReducesGrassAndProducesHay() {
Hay hay = field.cutGrass(100);
assertNotNull(hay);
assertEquals(100, hay.getUnits());
assertEquals(0, field.getGrass());
}
the method i need do write it for is :
Code:
public Hay cutGrass(int grassToCut)
{
if( grassToCut <= 0){
throw new IllegalArgumentException("Cannot cut less than one unit of grass"); // if grass cut if less then one, exception thrown
}
if( grassToCut > 100){
throw new IllegalArgumentException("Cannot cut more grass than field contains"); // if grass cut contains more then in field exception is thrown.
}
if (month >= 12){ // if month is more then or equal to 12 the grass cut goes is set back to 0.
grass =0;
}
report("cut " + grassToCut + " units of grass");
return hay;
}
any help or if needed more info please ask..
thanks