Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Food works only for a fixed amount of items #6

Open
dsantistevan opened this issue Jul 13, 2020 · 0 comments
Open

Food works only for a fixed amount of items #6

dsantistevan opened this issue Jul 13, 2020 · 0 comments

Comments

@dsantistevan
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant