"Hai, Amigo! Ini beberapa tugas yang melibatkan pembuatan kelas dan objek."
2
Tugas
Java Syntax, level 5, pelajaran 5
Creating a cat
Sally Johnson has 500 cats, and another couple hundred furry creatures come to visit them as guests. So Sally decided to create a special cat photo album to record their features: name, age, weight and strength. "Why strength?" you ask. You'll see why we need strength in the next task. For now, we'll implement the Cat class.
4
Tugas
Java Syntax, level 5, pelajaran 5
Implement the fight method
Theo Baslim, a retired colonel, saw active combat as a young man, but now he is bored. When he learned that his neighbor Sally Johnson had acquired five hundred cats, and he offered to arrange bloodless feline battles (she wouldn't go for bloody battles). There's just one small detail: we need to implement a mechanism for cats to fight based on weight, age and strength.
4
Tugas
Java Syntax, level 5, pelajaran 5
Getters and setters for the Dog class
Let's create a Dog class. A dog should have a name and age, and getters and setters for these variables. A getter is a method that returns a variable's current value to the caller. A setter is a dog breed. However, though we are talking about dogs at the moment, this term actually isn't about dogs: in the context of programming, a setter is a method that sets a variable to a new value.
2
Tugas
Java Syntax, level 5, pelajaran 5
The Three "Muscateers"
A couple of tasks ago, students at the secret CodeGym center created the class Cat. Now it's time to actually create some cats in the image and likeness of the Cat class, or rather using the class as a pattern. There should be three cats. Breathe life (or specific data) into this trio.
4
Tugas
Java Syntax, level 5, pelajaran 5
Feline carnage
If you think all cats are cute fur balls, you probably haven't encountered alley cats in a heated struggle for supremacy in a certain area. It's time for you to meet them. More precisely, it's time to simulate a decisive battle between the three most powerful cats in the neighborhood. For combat, we will use the boolean fight(Cat anotherCat) method.
2
Tugas
Java Syntax, level 5, pelajaran 5
People
Creating a person is a huge responsibility. But it's not our place to teach you that. We need to describe and show how to create different classes, and your task is to understand these concepts and put them into practice. In particular, let's create a Person class. A person should have a name, age, address, and sex. Have we forgotten anything?
8
Tugas
Java Syntax, level 5, pelajaran 5
Arithmetic mean
The arithmetic mean is a value that is often used in statistics. A hospital's average temperature is precisely calculated using the formula for the arithmetic mean. And now we've come to the critical part: write a program that takes numbers from the keyboard, sums them, and then calculates the mean until the user enters the number -1.
2
Tugas
Java Syntax, level 5, pelajaran 5
Getters and setters for the Person class
We create a pair of methods (get and set) for each variable to allow other classes to change their values. The get method's task is to return the current value of the variable to the caller. The set method's task is to set a new value for the variable. Let's create a Person class with a name, age, and sex, and define getters and setters for all the fields.