「おい、兵士よ!」
「こんにちは、船長!」
「素晴らしいニュースがあります。スキルを強化するための演習をいくつか紹介します。毎日実行すると、スキルは驚くべきスピードで成長します。これらは IntelliJ IDEA 用に特別に作成されました。」
「以前の演習は新人向けでした。ベテラン向けに、さらに高度なボーナス演習を追加しました。ベテラン向けです。」
16
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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
タスク
Java Core, レベル 5, レッスン 12
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.