Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task2.0 #2187

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Task2.0 #2187

wants to merge 2 commits into from

Conversation

Volikk
Copy link

@Volikk Volikk commented Oct 21, 2024

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on implementing the functionality! 🎉 While the code works well, there are a few areas for improvement. Consider using abstract references for better polymorphism, and remember to apply access modifiers to follow encapsulation principles. Also, tidy up by removing redundant empty lines. Addressing these points will enhance your code quality. Keep up the good work and continue learning from these insights!

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

@@ -0,0 +1,13 @@
package core.basesyntax;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the redundant empty line after the package declaration.

public void doWork() {
System.out.println("Bulldozer started its work.");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the redundant empty line after the method.

public class Excavator extends Machine {
@Override
public void doWork() {
System.out.println("Excavator started its work.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message in the doWork method should indicate the type of Machine that is working, which is correct here as it mentions Excavator.


@Override
public void stopWork() {
System.out.println("Excavator stopped working.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message in the stopWork method should indicate the type of Machine that is working, which is correct here as it mentions Excavator.

@@ -0,0 +1,7 @@
package core.basesyntax;

abstract class Machine {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using access modifiers for the class declaration to follow the encapsulation principle. For example, you might want to make this class public if it is intended to be accessed from outside its package.

@@ -1,5 +1,11 @@
package core.basesyntax;

public class MainApp {

public static void main(String[] args) {
Machine[] machines = { new Truck(), new Bulldozer(), new Excavator() };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using abstract references instead of specific ones where possible. According to the checklist, it's better to use Machine as the type for the elements in the machines array to allow for polymorphism.

public class Truck extends Machine {
@Override
public void doWork() {
System.out.println("Truck started its work.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message should indicate what type of Machine is working right now. The current message 'Truck started its work.' is informative and correctly indicates the type of Machine.


@Override
public void stopWork() {
System.out.println("Truck stopped working.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message should indicate what type of Machine is working right now. The current message 'Truck stopped working.' is informative and correctly indicates the type of Machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants