Java

OOP GUIDE / WORK

 

COLLIDABLE INTERFACE

 

Topics

·       Interface design

 

TASK – PART 1 – INTERFACE DESIGN

Let’s consider a scenario where you are creating a video game.  You are working with all sorts of objects that need to be drawn on the screen.  Some of these objects have to be checked to see if they collide with other objects.

 

We will call objects that can be checked for collisions, Collidable objects.  Of course, if you prefer, you can use a name such as CollisionCheckable, or even just something like Collision.

 

Collidable is an ability of an object.  So we can use an interface here.

 

You are asked to determine which methods you think you need to have to check if an object is colliding with another object and write the interface.

There is no need to actually use the interface.