Joomla Vorlagen by Website Hosting

PL1 - 2nd laboratory

Objectives

Students will learn how to create a class, a constructor, an instance variable and they also understand an object  composition(compose one object from one or more others).

Scenatio

Download and open project - lab02.zip

Create a new class  „House.“

Create a non-parametric constructor of House to create a green roof consisting of a triangle (a Triangle object) and gray masonry (a Rectangle object).

Create the moveRight and moveDown methods to cause the house to move a certain number of pixels in the direction you want. Number of pixels will be parameter.

Create the getX and getY methods to return the house position.

Create a setPosition method.

Create a parametric constructor of House that allows to define initial position.

Create instance of a House when an user do double-click to the canvas(method handleMouseClick is called in that case).

Move a last create instance of House with buttons (handleButtonXXX).

Make sure that the house is not placed in a position outside the canvas range - use operator modulo

Homework

Work on assigned individual tasks. These are "TODO" 1-6, which are like comments in the Pacman class. Easy to view is in eclipse - "Window / Show View / Tasks".

UML diagrams

Overview of a class House

pl1 02 01

 

Event handling

pj2 02 02