We began designing and implementing our
MenuItem classes in
the last studio. Let’s continue working on these
classes by adding some methods.
To review, here are the details you have from the restaurant owner:
Based on these details, you need to include some instance methods:
Starting with pen and paper (or your favorite notes application on your
laptop), sketch out the methods that you need to add to these classes. List the
method names and access levels, along with the types of all input and return
parameters. Also, consider whether any methods should be
Once you have sketched out your methods, pair with a classmate and take turns presenting your designs. Class design can be subjective, so it’s important to properly think and talk through your choices before coding.
While your partner is presenting their design, ask questions about why they made the decisions they did. Consider other use cases that might come up, and see if their design fits with those.
Restaurant Menuproject. Create a branch in your repository for your Lesson 4 Studio solution. For the studio, make sure all of your work is in that branch.
Restaurant, and add a
Mainmethod to test your classes:
In the previous studio, you should have created a repository on GitHub for your restaurant project. Since you just modified that project in this studio, commit your changes and push them up to the same repository.
If a user tries to add an item that is already on the menu, print a message that warns the user about the duplicate. Also, prevent the duplicate from being added to the menu.