Skip to content

created classes and overrode methods doWork and stopWorks. Created Ma…#2603

Open
drpacci wants to merge 5 commits into
mate-academy:masterfrom
drpacci:hw-jv-oop-lesson-solution1
Open

created classes and overrode methods doWork and stopWorks. Created Ma…#2603
drpacci wants to merge 5 commits into
mate-academy:masterfrom
drpacci:hw-jv-oop-lesson-solution1

Conversation

@drpacci

@drpacci drpacci commented Jun 21, 2026

Copy link
Copy Markdown

…chine's array and called those methods in the loop.

…chine's array and called those methods in the loop.

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

Copy link
Copy Markdown

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 implemented and functionally correct: Machine is abstract with doWork() and stopWork(), Truck, Bulldozer, and Excavator extend it and override both methods, and MainApp uses a Machine[] to call these methods polymorphically. The remaining issues are non-blocking: several messages have a typo (Buildozer instead of Bulldozer) and slightly awkward grammar (e.g., "Truck stop its work"), and there are redundant empty lines after class declarations and between methods, which conflict with [CHECKLIST ITEM #1] and [CHECKLIST ITEM #2]. These do not break functionality but you should still fix them: update all printed messages to use the correct machine names and clear past-tense English (for example, "Bulldozer started working" / "Bulldozer stopped working"), and remove extra blank lines immediately after class headers, between methods, and before closing braces. Also pay attention to the linter hints: add the missing space in MainApp.java line 5 (e.g., String[] args) and ensure there is a blank line before the first method in Machine.java as Checkstyle requires. Overall, the OOP structure and polymorphism are well done; polishing the messages and formatting will bring your code fully in line with the checklist and professional Java style.


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

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

public class Bulldozer extends Machine {

public void doWork() {
System.out.println("Buildozer started its 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 #2: messages should clearly and correctly indicate the machine type and what is happening. Here the type name is misspelled (Buildozer vs Bulldozer), and the wording/tense could be more precise (e.g., "Bulldozer started its work").

}

public void stopWork() {
System.out.println("Buildozer stop its 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 also violates checklist item #2 for the same reasons as above: the type name is inconsistent (Buildozer), and the message is not grammatically correct ("stop its work" vs "stopped its work").

Comment on lines +3 to +4
public class Bulldozer extends Machine {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #1 says "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." The blank line between the class declaration and first method matches the bad example and should be removed.

public void doWork() {
System.out.println("Buildozer started its 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.

Checklist item #1 warns against redundant empty lines after method signatures; the empty line after this method declaration/body section falls into that pattern.

Comment on lines +3 to +4
public class Bulldozer extends Machine {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #1: there is a redundant empty line after the abstract class declaration; align with the improved example by keeping class and members directly together.


public void doWork() {
System.out.println("Buildozer started its 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.

Checklist item #1: this extra blank line between the abstract methods and the closing brace is unnecessary and matches the "Bad example" pattern.

public class Bulldozer extends Machine {

public void doWork() {
System.out.println("Buildozer started its 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.

Checklist item #1: there is an extra empty line between the array initialization and the loop, similar to the bad example of redundant empty lines after code blocks.

public class Excavator extends Machine {

public void doWork() {
System.out.println("Excavator started its 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.

The message misspells the class/type name (Buildozer instead of Bulldozer) and "started its work" is OK but could be made more natural (e.g., "Bulldozer started working") to better satisfy the "informative messages" checklist requirement.

}

public void stopWork() {
System.out.println("Excavator stop its 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.

Same typo (Buildozer) and the phrase "stop its work" is grammatically incorrect; consider "Bulldozer stopped its work" or "Bulldozer stopped working" to make the message clear and informative as required by the checklist.

public abstract class Machine {

public abstract void doWork();
public abstract void stopWork();

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: Write informative messages in methods. - Use English only and make messages informative - The message should indicate what type of Machine is working right now Truck, Bulldozer or Excavator. Here "Buildozer" is misspelled and the sentence is slightly ungrammatical; consider something like "Bulldozer started its work".


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.

Although functionally correct, you can better follow the "use abstract references" checklist idea by instantiating via the interface but spacing the array more cleanly and consistently (e.g. Machine[] machines = { new Truck(), new Bulldozer(), new Excavator() };). The main point is already satisfied (using Machine as the type), so just keep this in mind stylistically.

public class MainApp {
public static void main(String[] args) {
Machine[] machines = {new Truck(), new Bulldozer(), 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 checklist item about informative messages: the machine type is misspelled as Buildozer instead of Bulldozer, and the message should clearly and correctly indicate the machine type.

for (Machine m : machines) {
m.doWork();
m.stopWork();
}

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 also violates the informative message checklist: consider correcting the spelling (Bulldozer) and improving the phrasing to clearly say that the bulldozer has stopped working.

public class Truck extends Machine {

public void doWork() {
System.out.println("Truck started its 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 message violates checklist item #2: "Write informative messages in methods". The machine type is misspelled (Buildozer instead of Bulldozer), so the message does not clearly and correctly indicate which machine is working.

}

public void stopWork() {
System.out.println("Truck stop its 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 also violates checklist item #2: the type name is misspelled (Buildozer), and the phrase "stop its work" is not clear or grammatically correct. Use a clear English sentence that states that the Bulldozer has stopped working.

Comment on lines +3 to +4
public class Truck extends Machine {

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." The blank line after the class declaration is exactly the pattern shown in the bad example.

public void doWork() {
System.out.println("Truck started its 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 extra blank line between methods also matches the "Bad example" in checklist item #1 about redundant empty lines between method signatures and other code.

}

public void stopWork() {
System.out.println("Truck stop its 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.

Here the stopWork message uses "Truck stop its work", which is grammatically incorrect and less informative; per checklist item #2 you should use a clear English message that states the Truck has stopped working.

Comment on lines +3 to +4
public class Truck extends Machine {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In this class too, the blank line right after class Truck extends Machine { matches the redundant empty-line pattern warned about in checklist item #1.

public void doWork() {
System.out.println("Truck started its 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 extra blank line between methods is another instance of the redundant empty lines that checklist item #1 asks you to avoid.

}

public void stopWork() {
System.out.println("Truck stop its 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.

The stopWork message uses "Excavator stop its work"; to comply with checklist item #2, rephrase to correct English that clearly indicates the Excavator has stopped working.

Comment on lines +3 to +4
public class Truck extends Machine {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In Machine, the blank line right after the class declaration is the same pattern shown in the bad example for checklist item #1 (redundant empty line after class declaration).


public void doWork() {
System.out.println("Truck started its 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 extra blank line before the closing brace is another redundant empty line per checklist item #1.

public class Truck extends Machine {

public void doWork() {
System.out.println("Truck started its 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.

In MainApp, the blank line between the array initialization and the for loop matches the redundant empty-line pattern that checklist item #1 tells you to avoid.

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

Copy link
Copy Markdown

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 functional requirements are correctly implemented: Machine is an abstract class with doWork() and stopWork(), Truck, Bulldozer, and Excavator extend it and override both methods, and MainApp uses a Machine[] and a loop to call these methods polymorphically. The printed messages are in clear English and explicitly mention each machine type, which satisfies the requirement for informative outputs. There are some remaining style issues with redundant empty lines (for example, extra blank lines in Excavator.java between the package and class declaration, before the for loop, and before the closing brace, and a similar extra blank line in Truck.java), but these are cosmetic and do not block functionality. You should still clean those up to align with the checklist item about avoiding redundant empty lines, but they do not prevent this solution from meeting the task’s main goals. Overall, the structure, inheritance, and polymorphic use of Machine and its subclasses are all implemented correctly—well done.


✨ 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,12 @@
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 Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature. There is an extra blank line between the package and class declaration that should be removed.

public class Excavator extends Machine {
@Override
public void doWork() {
System.out.println("Excavator started its 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 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 abstract methods and the closing brace.

public class Excavator extends Machine {
@Override
public void doWork() {
System.out.println("Excavator started its 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 Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature. The blank line before the for loop is redundant in this simple method and should be removed.

@@ -0,0 +1,12 @@
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 Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature. There is an extra blank line between the package and class declaration that should be removed.

@@ -0,0 +1,12 @@
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: Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature. The blank line between the package and class declaration is considered redundant in this context.

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