Table of Contents

Lesson 2

Introduction to OOP

Objectives

Documentation

Java Oracle Tutorial - OOP Concepts
Principiile programarii orientate pe obiecte
Ciclul de viaţă al obiectelor

Exercises

Exercise 1

A class Sensor contains:

Write a class which models the class Sensor . Write a class TestSensor which test Sensor class.

Exercise 2

A class called Circle contains:

Write a class which models the class Circle. Write a class TestCircle which test Circle class.

Exercise 3

A class called Author contains:

Write the Author class. Also write a test program called TestAuthor to test the constructor and public methods.

Exercise 4

A class called MyPoint, which models a 2D point with x and y coordinates contains:

Write the code for the class MyPoint. Also write a test class (called TestMyPoint) to test all the methods defined in the class.

Exercise 5

Modify Flower class from Ciclul de viaţă al obiectelor so that it keeps track of the number of constructed object. Add a method which returns the number of constructed objects. Use 'static' variables and methods for implementing this task.