"Hi, Amigo! Nami-miss ko na ang ating mga aralin. Narito ang ilang mga gawain upang magsanay ng object initialization:"
4
Gawain
Java Syntax, antas, aralin
Create a Friend class
Let's make up our own invisible friends, give them some qualities, and then go play with them, just like the other loners do! No? Okay, another time. We'll get through today by creating a friend template, i.e. a Friend class. And we'll make up three initializers for it: name, age and sex; only name and age; and only name.
8
Gawain
Java Syntax, antas, aralin
Initializing cats
This task is dedicated to the mysterious and beautiful creatures we call cats. Create a Cat class and define five initializers (only name; name plus weight and age; only weight and color; name and age; weight, color, and address). We need valid cats: they can't exist without a weight and age. Alas, there are cats without names and homes.
2
Gawain
Java Syntax, antas, aralin
Create a Dog class
The "Man's Best Friend" Bureau has decided to conduct a full census of Terra's dog population. To do this, they need an application that has a special Dog class. The only thing we can learn (or assign) about some dogs is a name. For other pooches, we also know the height. Finally, complete information about other dogs also includes color. This means that we need three initializers.
2
Gawain
Java Syntax, antas, aralin
Create a Circle class
A circle is the most perfect shape in the world. At least that's what the roly polies on the 2D planet 2piR think. The roly polies needed a registration program to identify fellow roly polies in the plane. The challenge is that different data is known about various roly polies. Let's help them: create a Circle class with three initializers.
4
Gawain
Java Syntax, antas, aralin
Let's put together a rectangle
OKEA sells unassembled space shuttles. They are all rectangular (we don't know why). These guys ordered a program from Company X for automatically generating shuttle instructions. You've been assigned to create a rectangle class and initializer methods for whatever life might throw at it.
2
Gawain
Java Syntax, antas, aralin
A programmer creates a person
Let's create a new person... Actually, that would be better done elsewhere. In our case, we'll just create a template for a person. That is, a Person class. We'll give it fields (name and age). To create new Person objects quickly and confidently, we'll write an initialize(String name, int age) method, where we will initialize these fields.
2
Gawain
Java Syntax, antas, aralin
Initializing objects
We'll initialize objects however we want! In this task, someone previously created the Person class, but their implementation doesn't quite suit us. Something needs to be fixed: we need to rewrite the program so that one and only one initialize method initializes all the Person class's instance variables.