"Hoy, kawal!"
"Magandang araw, Kapitan!"
"Mayroon akong kahanga-hangang balita para sa iyo. Narito ang ilang mga pagsasanay upang palakasin ang iyong mga kasanayan. Gawin ang mga ito araw-araw at ang iyong mga kasanayan ay lalago nang napakabilis. Ang mga ito ay nilikha lalo na para sa IntelliJ IDEA."
"Yung mga nakaraang exercise ay para sa mga rookies. Nagdagdag ako ng ilang mas advanced na bonus exercises para sa mga old-timers. Para lang sa mga beterano."
16
Gawain
Java Core, antas, aralin
Different methods for different types
So, polymorphism. You haven't forgotten about it, have you? Good. Then let's complete the following task: Read data from the console until the word "exit" is entered. For each value (except "exit"), call the print method. The correct print method depends on the value. For example, if the value contains a period, then use the print method for Double. If the value is a number between 0 and 128, then use the method for short.
4
Gawain
Java Core, antas, aralin
Brain training
Find the error in the logic: Duck should correctly implement the CanMove interface. Fix the error so you get the correct result.
8
Gawain
Java Core, antas, aralin
OOP: Method overloading
Overload the Tree class's info(Object s) method twice to get 3 methods: info(Object s), info(Number s), and info(String s). Then study the info(Object s) method and create similar functionality in the new methods. For example, the result for the info(Number s) method might be: "Tree No. 123, Number method, parameter Short.
16
Gawain
Java Core, antas, aralin
Reinforce the singleton pattern
Let's delve into the singleton pattern by considering the sun and planets of the solar system. First, do an Internet search and find some example of "lazy initialization" using the singleton pattern. Create three singleton classes "in its likeness and image": Sun, Moon and Earth. Then implement the Planet interface in them. And do a couple other operations.
8
Gawain
Java Core, antas, aralin
Overloading constructors
In this task, we need to create the Solution class and its descendant SubSolution. We need to create constructors for this descendant and fix their access modifiers so that we get three constructors with different modifiers (except private).
8
Gawain
Java Core, antas, aralin
Order of loading variables
Time for a useful debugging task. You have code you need to dig into: figure out what gets initialized and in what order. You can do this using the IntelliJ IDEA debugger and breakpoints. Then fix the initialization order so you get a specific result.
8
Gawain
Java Core, antas, aralin
File in a static block
Initialize the variable Statics.FILE_NAME to the full path to a data file that contains several lines. Then, in the static block, read all the lines from the file named Statics.FILE_NAME, and add them separately to the List lines.
8
Gawain
Java Core, antas, aralin
Debug, debug, and again debug
Again and again, we search for other people's mistakes and correct them... That's our lot in life as programmers. Our program again displays something wrong: An bug has crept in (just one!). Find it and neutralize it! Use the IntelliJ IDEA debugger to do this.
16
Gawain
Java Core, antas, aralin
Request parser
Read a URL from the console. Then display a space-delimited list of all the parameters (The parameters follow the "?" and are separated by "&", e.g. "lvl=15"). The URL contains at least 1 parameter. If the obj parameter is present, pass its value to the relevant alert method.
8
Gawain
Java Core, antas, aralin
OOP: The Euro is money too
Correct the Euro class to avoid a StackOverflowError. And, strange as it may seem, the Euro should inherit the Money class, which should implement the getAmount method.
8
Gawain
Java Core, antas, aralin
Mastering the static block
Let's create Plane and Helicopter classes that implement the CanFly interface. Then in the Solution class's static method, we need to read a String from the console. If it's equal to "helicopter" ("plane"), we'll assign a Helicopter (Plane) object to the static CanFly field result. In the static block, initialize the CanFly field result by calling the reset method.
8
Gawain
Java Core, antas, aralin
Template pattern
Let's create an algorithm for baristas in the DrinkMaker class. It will choose a suitable cup, add ingredients, and pour liquid. Also, we'll inherit DrinkMaker to create highly specialized algorithms for tea and latte.
8
Gawain
Java Core, antas, aralin
Factorial
On Planet Linear Chaos, infants are expected to find the factorial of two-digit numbers. Well, we'll behave like adults, like programmers, and write a method that calculates factorials up to the entered number.