Pets and boxes

Report a typo

There is a class called Box which can be defined as a container for storing different things. But as we all know, pets prefer using boxes for other things: playing, sleeping, hiding, etc.

Finish the Box class so that it could be applied only to objects of subclasses of Animal class. Inside this class implement anadd(...object...) method for adding the object of Animal class or its subclass to a Box object.

Write a program in Java 17
class Box //...finish the code of the class

// Don't change the code below
class Animal { }
___

Create a free account to access the full topic