Java code for the object oriented course