-
Notifications
You must be signed in to change notification settings - Fork 59
Lesson 4 (Classes Part 2)
Courtney Frey edited this page Apr 14, 2022
·
2 revisions
- How to customize fields with the keywords
final
andstatic
. - How to add methods to a class and call those methods.
- The difference between instance methods and static methods.
- How to override the default
toString
andequals
methods for a class. - How to auto-generate an
equals
method using the tools in IntelliJ.
- Graded Assignment #2 is open, and it is due soon. Keep working on your project! After today, you will have enough skill to make significant progress.
- Welcome to Days 5 - 7!
- Assignment 1 due end of Day 8
-
Day 5:
- Lesson 4
-
Days 6 & 7:
- Assignment 1 work days
- Catch up days
- Q&A for the prep work exercises.
- The words
final
andstatic
can be confusing if the students take latter term to mean "unchanging". Be sure to review what each keyword means and the results of applying each one to a field. - Pay particular attention to why we want to use the
equals()
method rather than the==
operator to compare objects.- Review the difference between comparing identity vs. equality.
- Note the default behavior of the
equals
method.
- Review why students will usually want to code their own
toString
andequals
methods. - Review how to call methods using
ClassName.methodName
vs.objectName.methodName
.- When and why does it matter which syntax to use?
- Review the objectives for today's studio task. Alternatively, if the TFs raise concerns about how the students are progressing on assignment 2, replace the studio intro with a review of the assignment 2 objectives.
- This studio extends the restaurant menu that the students started in class 3. Today, they will create methods to add and remove menu items, as well as to print the menu.
- Pace the studio carefully. Just like last class, the students will begin planning their class methods using pen and paper, then pair up to share their ideas.
- Provide ample time for this sharing. However, the students will need more time to get their methods coded compared to the last studio, so plan accordingly.
- As the students get further into their coding, rotate through your group and have them demonstrate their program. Verify that they can add or remove new menu items and that they can print a menu to the screen.
- Just like the last studio, it is important to make sure the students' code works and matches their design.
- Encourage students who are not following the principles of OOP to consider how to better encapsulate their methods.
- If a student's code differs significantly from their design, ask them (carefully) about why they decided to adapt their plan.