"คุณพร้อมสำหรับงานใหม่ๆ มากมายหรือยัง ได้เวลาท้าทายตัวเองแล้ว"
Set of cats
You need to create a set of cats. This requires a public static Cat class. Then implement the createCats method, which should create a Set of cats and add 3 cats to it. In the main method, remove one cat from Set cats. Finally, implement the printCats method. It should display all the cats that remain in the set.
Let's add animals to sets. First, we'll create Cat and Dog classes and then createCats and createDogs methods, which will return sets with dogs and cats. We'll write a join method that returns the union of the dog and cat sets. To handle any unfriendliness, we'll create the removeCats method, which removes cats from pets. And finally — the printPets method, which displays everything in pets.
Shared last names and first names
We're ready to discover our namesakes! We just need to write a program to realize this heartwarming goal. To start, let's create a Map, where we will add people represented by (last name, first name) pairs. Let there be ten of them, with some of them sharing last names and some of them sharing first names. After that, we'll display the contents of the Map on the screen.
Minimum of N numbers
The programmer searches for minima and maxima wherever he can—among two numbers, in an array, in a list... Students at the secret CodeGym center study lists on the eighth level, so this important moment has come for you. Even now, you can try to find the minimum in a list of n numbers. But before you look for the minimum, you need to create a list. What are you waiting for?
Once diners get over their initial reservations about the proper color of breakfast foods, they fall in love with green eggs and ham. Sam-I-Am has big plans to open a national chain of restaurants featuring his signature dish. He'll launch the Green Eggs and Ham restaurant chain as soon as he can find suppliers of properly colored eggs. We will write a program that replaces the text "green eggs and ham" with "Green Eggs And Ham".
Make a family
Let's try to create a program for a family census. To do this, we'll write a Human class with String name, boolean sex, int age, and ArrayList children fields. To practice, create objects and fill them with data so we end up with two grandparents, two grandmothers, a father, a mother, and three children. Display the objects on the screen.
Not everyone can be static! And if a static modifier ends up where it shouldn't be, anything could happen! This is exactly what happened in the code you'll see once you open this task: one static modifier ended up in the wrong place. Help the program compile by putting the modifier where it belongs! Thanks.
Onboard the CodeGym spaceship, students in Levels 7-8 completed a multi-stage contest to see who could complete tasks the fastest. Among the 20 semi-finalists, the five with highest scores are winners. So, we have an array with the semi-finalists' scores (note that scores can be negative). We'll display the magnificent top five.
Working with dates
The Nebula-1 station receives spaceships only on odd days of the standard earth year (i.e. days when there have been an odd number of days since the beginning of the year). Let's find out if we can party on Nebula-1 today. To do this, we'll implement the isDateOdd(String date) method, which returns true if the number of days since the beginning of the year is odd, and otherwise returns false.
The time intervals "year" and "month", which have been adopted on Terra, are also used on other Federation planets and objects, including the CodeGym spaceship. But new extraterrestrial crew members are often confused by these earthly months. Let's help them: write a program that uses collections to display a number's month given its name.
You've probably seen how applications are updated. This happens if changes are made to their code. At the secret CodeGym center, you've been given code that needs to be changed (you need to add new functionality). The program currently determines which family lives in the house with the specified number. After your intervention, it should output the family's city of residence.
Task about algorithms
You probably already know the ordered isomorphs of Planet Linear Chaos, who like sorting algorithms because they use them to think. Here's a little task for isomorphs in elementary school: enter 20 words from the keyboard and display them in alphabetical order. But how do we sort them? Come up with the answer yourself! You're practically a linear isomorph!