You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Food class wouldn't be able to handle a different item that the ones listed there, and if an indefinite amount of items were added this code wouldn't be able to handle it.
Food(int itemno,int quantity)
{
this.itemno=itemno;
this.quantity=quantity;
switch(itemno)
{
case 1:price=quantity*50;
break;
case 2:price=quantity*60;
break;
case 3:price=quantity*70;
break;
case 4:price=quantity*30;
break;
}
}
This is a violation to the Open Closed Principle of SOLID design, because this is not open for extension.
The text was updated successfully, but these errors were encountered:
The Food class wouldn't be able to handle a different item that the ones listed there, and if an indefinite amount of items were added this code wouldn't be able to handle it.
This is a violation to the Open Closed Principle of SOLID design, because this is not open for extension.
The text was updated successfully, but these errors were encountered: