Hotel-Management-Project-Java
Hotel-Management-Project-Java copied to clipboard
Food works only for a fixed amount of items
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.