We began designing and implementing our Menu
and 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 static
.
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 Menu
project. Open the terminal in IntelliJ and 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
package, add the methods you designed to your Menu
and
MenuItem
classes.Restaurant
, and add a
public static void main(String[] args)
method.main
method to test your classes: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.
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. However, you must still submit the URL for your repository on Canvas.