Skip to content

Implement doWork() and stopWork() methods#2543

Open
YKorniienkova wants to merge 2 commits intomate-academy:masterfrom
YKorniienkova:feature/jv-oop1
Open

Implement doWork() and stopWork() methods#2543
YKorniienkova wants to merge 2 commits intomate-academy:masterfrom
YKorniienkova:feature/jv-oop1

Conversation

@YKorniienkova
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@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.

Review Summary

Your solution is approved because all core requirements are correctly implemented: Machine is abstract with doWork() and stopWork(), each of Truck, Bulldozer, and Excavator extends it and prints clear English messages, and MainApp creates a Machine[] and iterates over it calling both methods. Functionality appears correct and there are no blockers that would prevent the task from working as intended.

There are a couple of style and checklist-related improvements you should still make on your own. First, remove redundant empty lines: after the package line and between methods in Truck.java and Bulldozer.java, between doWork() and stopWork() in Machine.java and Excavator.java, and leading/trailing or extra blank lines in MainApp.java [CHECKLIST ITEM #1]. Second, in MainApp, prefer using the abstraction for your variables, e.g. Machine truck = new Truck(); instead of Truck truck = new Truck();, or even create the array directly as Machine[] machines = { new Truck(), new Bulldozer(), new Excavator() }; to better demonstrate polymorphism [CHECKLIST ITEM #3].

Overall, your class hierarchy and behavior are solid; just keep polishing the style and use of abstractions to align fully with the checklist and good OOP practices.


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

Footnotes

  1. Rate AI review example

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a redundant empty line after the package declaration. This violates the checklist item: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the blank line to follow the style guidance. (See checklist)

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This blank line sits between the two method definitions and is redundant. This violates the checklist item: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the blank line between doWork() and stopWork(). (See checklist)


public class MainApp {

public static void main(String[] args) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This file contains redundant empty lines (leading/trailing blank lines). This violates the checklist item: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove unnecessary blank lines so the file has no extraneous empty lines at the top or bottom. See checklist for details .

Comment on lines +5 to +7
Truck truck = new Truck();
Bulldozer bulldozer = new Bulldozer();
Excavator excavator = new Excavator();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You are creating variables with concrete types instead of using the abstraction. This violates the checklist item: "Use abstract references instead of specific ones where possible:" — prefer Machine truck = new Truck();, Machine bulldozer = new Bulldozer();, and Machine excavator = new Excavator(); so the code depends on the abstraction and demonstrates polymorphism (the rest of your loop can remain unchanged). See checklist for wording and rationale .

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a redundant empty line between the two method definitions. This violates the checklist item: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the blank line between doWork() and stopWork() (line 8) so methods appear consecutively.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This file contains a redundant empty line. This violates the checklist item: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the blank line to keep methods compact.


public abstract class Machine {
public abstract void doWork();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is an unnecessary blank line between method declarations. This violates the checklist item: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the empty line between doWork() and stopWork().

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This file has a redundant empty line after the package declaration. This violates the checklist item: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the blank line to keep the file compact.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is an unnecessary blank line between the two method definitions. This violates the checklist item: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove this blank line so methods follow one another without extra empty lines.

Copy link
Copy Markdown

@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.

Review Summary

I am approving your solution because all functional requirements are correctly implemented: Machine is an abstract class with the required methods, Truck/Bulldozer/Excavator extend it and override doWork()/stopWork(), and MainApp creates an array of machines and calls these methods in a loop. There are no critical blockers or broken functionality.

For future improvements, in MainApp.java you currently declare concrete variables like Truck truck = new Truck(); (around the top of main). To better follow polymorphism and the checklist recommendation [CHECKLIST ITEM #3], prefer Machine truck = new Truck(); or directly initialize the array as Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()};. Also, in Bulldozer.java, Excavator.java, and Truck.java, remove redundant empty lines after the package declarations, after the class declaration, and between methods to align with [CHECKLIST ITEM #1]. These are style issues only and don’t affect correctness, but cleaning them up will help you match typical Java style and project guidelines.

Overall, you met the core task goals well; consider the above as polish for future submissions.


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

Footnotes

  1. Rate AI review example

Comment on lines +5 to +7
Truck truck = new Truck();
Bulldozer bulldozer = new Bulldozer();
Excavator excavator = new Excavator();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates the checklist item: "Use abstract references instead of specific ones where possible." You declare concrete variables (Truck truck = new Truck();, Bulldozer bulldozer = new Bulldozer();, Excavator excavator = new Excavator();) instead of using the abstraction. Consider using Machine truck = new Truck(); or directly initialize the array as Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; so the code depends on the Machine abstraction.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the redundant blank line here (it's unnecessary and should be deleted).

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the redundant blank line between methods so the class has no unnecessary empty lines.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the redundant empty line after the package declaration.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the extra blank line between the end of doWork() and the @Override for stopWork() so methods are not separated by redundant empty lines.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the redundant empty line after the package declaration.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the extra blank line between the end of doWork() and the @Override for stopWork() so methods aren't separated by redundant empty lines.

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