0

Ok, I have this code where I have to add 5 Properties

Returns either -1 if the array is full, -2 if property is null, -3 if the plot is not contained by the MgmtCo plot, -4 of the plot overlaps any other property, or the index in the array where the property was added successfully. This is my code, it gives me an error in my Junit test when I try to add the fourth property public int addProperty(Property property){ int empty; if(property==null){ return -2; } for(empty =0; empty<5; empty++) { if(properties[empty]==null){ countindex = empty; break; } } if(countindex==MAX_PROPERTY){ return -1; } else { for( empty= 0; empty<countindex; empty++){ if(properties[empty].getPlot().overlaps(property.getPlot())) return -4; } } if(!plot.encompasses(property.getPlot())) { return -3; } else { properties[countindex]=property; countindex++; return countindex; } }

24th Apr 2020, 9:19 PM
Angelica
Angelica - avatar
3 ответов
+ 2
Where is property class? What is size of properties[] array? Its better to save code in playground and share link.. Otherwise guessing won't help... Difficult to fing errors.. So please try to share full code, then some one try to help you to correct it...
24th Apr 2020, 9:45 PM
Jayakrishna 🇮🇳
0
it has a size of 5
24th Apr 2020, 11:15 PM
Angelica
Angelica - avatar
0
okay
24th Apr 2020, 11:15 PM
Angelica
Angelica - avatar