--- tags: Setup --- # Lecture 4 Setup/Prep In lecture 4, we will learn - how to share helper functions and common fields across classes We will continue building on the `Dillo`, `Boa`, and `Zoo` example from lecture 3. Download the [starter zip file for `lec04`](https://brown-cs18-master.github.io/content/lectures/04absclasses/initcode/lec04.zip). You can unzip this into your lectures project's `src` directory within IntelliJ. Remember to use `Right-Click-on-lec03 -> Mark Directory As -> Excluded` to hide your `lec03` directory while we work on `lec04`. ## Prep Last class, we saw the idea of an *interface* as the way to create a new type name in Java. In lecture 4, we'll build on that idea to better understand Java types, and add a helper function that should work with both `Dillo` and `Boa`. Our goal today is to learn how to design the `Dillo` and `Boa` classes to support the following `Zoo` class (which is already in the lec04 starter zip): ``` public class Zoo { IAnimal animal1; IAnimal animal2; public Zoo(IAnimal ani1, IAnimal ani2) { this.animal1 = ani1; this.animal2 = ani2; } /** Checks whether all animals in the zoo are normal size @return string indicating whether check passed or failed **/ public String healthCheck() { if (animal1.isNormalSize() && animal2.isNormalSize()) { return "Passed"; } else { return "Failed"; } } } ``` We will say that a normal size `Boa` has length between 12 and 24 (inclusive) and a normal size `Dillo` has length between 30 and 60 (inclusive). Things to think about: - In which class should we write the `isNormalSize` method? - Given that the `isNormalSize` computation is similar across `Boa` and `Dillo`, might we want a helper function? If so, where should that go?