I\'m a newbie in java. I\'m writing a class where the constructor must check the price parameter and ensure it is not a negative number. And if it is negative, it must set
Your getprice should simply be written as :
getprice
return price < 0 ? 0 : price;
Btw, nice to see that a stackoverflow error is solved by stackoverflow.com