Personally, I only understood the OOP theory (explanation generalization) about classes by observing their behavior in specific exemplar situations e.g. exact same code behaves differently when included in a package scoped class I.e. public, friend or private vs a module (which I call free-range cos it can do it’s thing 🎶whenever, wherever🎶).
@futurebird Seriously old school, but could you fold it into an activity about coding a text adventure? It always seems fun to make simple things like that (and you can get creative making a little "world"), and it strikes me that they could easily include a class hierarchy.
@futurebird With the caveat that this probably won’t actually work: a stereo system? Then they get to tangle with methods that apply to all components (play) or to just some of them (rewind, repeat) and then have arguments about how to subclass them?
(Although I think they’ll probably just stare blankly and say, “we’ll just listen to Spotify instead”)
@futurebird I always thought that non-static inner classes were interesting:
class A { class B {} }
class C {
public static void main(String[] args) {
A a = new A();
B b1 = a.new B();
B b2 = a.new B();
}
}
@futurebird
you might be better off working with a very simple video game world as a basis for examples; the real world of students and dinosaurs and other stuff is so messy and complicated it rapidly becomes an unfun mess in java.
For some reason my students don't have much interest in video games, they did like 8 years ago, but my current batch of student like interesting visual pattens and math more....
maybe I'll do something with the mandelbrot set? I haven't shown them that yet...
Could a "window" into the set make a good class? I could work out the image generation for them and maybe have them interact with it? hmmmmmm
OK now there is a thought.
Fractals are fun in any language that can handle complex recursion without memory leaks.
... oh, I forgot you want to use Java. 😉
Try using Java(code) to implement the behavior of a mathematical equation like solving a sine or cosine equation with a set of array or vector input variables.
Then add code to render the results on a XYZ chart (trigonometry & geometry maths) which can be done in a browser using CSS.
@futurebird I wonder if it even matters whether the example is person/student/teacher or dinosaur/herbivoreDino/carnivoreDino … Maybe it would be better to showcase it as a problem in need of solving? Start out with just e.g. two triceratopses, then a t-rex, then realize you have a bug and need to fix it twice, then creating a base class for the shared bits. So it's not pointless classification, but an actual, practical use case/need? Would that make it less boring?