Joomla Vorlagen by Website Hosting

PJ1 - 6th laboratory

Task 1

Create a class ResultInfo that will be Paintable and it will draw info about number of shoots.

pl1 lab06 01

Task 2

Create a class Ufo that will draw image Constant.UFO. Class will be Paintable and it will use GraphicsContext.drawImage.


pl1 lab06 02


Task 3

Place an object of Ufo on random position in the lower half – dimension of canvas will be set in constructor and position will be generated by Ufo.


Task 4

Create an interface Boundary with methods getXOfCorner, getYOfCorner, getWidth, getHeight, overlaps(other:Boundary). The method overlaps will be defined as a default method. The classes Ufo and Ball will implement the interface.


pl1 lab06 04


Task 5

When the ball hits the Ufo object increase a counter – value of the counter will be also displayed by an object of ResultInfo. For hit detection use the method overlaps. Show the hit counter with the number of shots.


Task 6

Place the Ufo object on new position in case that is hit (it will have method hit).


Task 7

Inherit from the class Ufo and create DisappearingUfo – it will be after every hit more transparent (10%). Use methods getGlobalAlpha/setGlobalAlpha in GraphicsContext. Use new class in simulation.


Solution (Task 1 - 6)