Class 5 Prep Exercises
- Class Design: In IntelliJ, create a new package
school
in the java-exercises
project. Add the class Student
that was discussed in the reading for this class to this new package. Add all getters and setters. Think about the access level each should have, and reduce the access level of at least one setter to less than public. Make sure you can defend your reasoning in words.
- More class design: In the
school
package, create a class Course
with at least three fields. Before diving into IntelliJ, use pen and paper to work through what these might be, including the data types, access levels, and whether it makes sense for any of them to be static
or final
. At least one of your fields should be an ArrayList
or HashMap
, and you should use your Student
class.
- More Cheese: More CheeseMvc, that is. Fire up this Spring Boot application, and create a new package within
org.launchcode.cheesemvc
named models
. (Your specific package name may be slightly different if you used a different project name. Put models
next to your controllers
package.) Within that package, create a Cheese
class that has name
and description
properties, along with getters and setters. Refactor the CheeseController
to use Cheese
objects rather than the strings that were used previously. You'll need to update your views as well.
- Review: With a pen and paper, write down descriptions of each of the following field types, along with an example of a situation where you might use each: public field, private field, static field, final field. If you get stuck, review the lesson on encapsulating data.