Abstract class and 3 inherited classes. Loop in main#2604
Conversation
…ain class to call these methods in a loop
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved because all core functional requirements are correctly implemented: Machine is an abstract class with public abstract void doWork() and public abstract void stopWork(), Truck, Bulldozer, and Excavator extend it and override these methods with clear English messages, and MainApp uses a Machine[] and polymorphism to call these methods in a loop. The design and access modifiers are appropriate, and there are no functional issues or violations that would block task completion.
The only remaining issues are minor style points about redundant empty lines, for example: in Bulldozer.java and Truck.java you have extra blank lines after the package declaration, immediately after the class declaration, and between methods, and in Excavator.java and MainApp.java there are unnecessary blank lines inside the class/method bodies. These relate to [CHECKLIST ITEM #1], which asks you to avoid redundant empty lines after class declarations or method signatures. To polish your code, remove those extra blank lines so that there is no blank line right after class Name { or directly between consecutive method signatures/bodies, and keep the body compact but readable.
Functionally you did a solid job: your messages are informative and clearly identify each machine, and you are correctly using the abstract type Machine for variables and arrays. Keep focusing on these small formatting details, as they will help you meet automated style checks and maintain clean, professional code in future tasks.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| @@ -0,0 +1,14 @@ | |||
| package core.basesyntax; | |||
|
|
|||
There was a problem hiding this comment.
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. You have an extra blank line between the package and class declaration and also inside the class body that should be removed.
| package core.basesyntax; | ||
|
|
||
| public class Bulldozer extends Machine { | ||
|
|
There was a problem hiding this comment.
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 unnecessary blank line right after the class declaration.
| public void doWork() { | ||
| System.out.println("A bulldozer started its work"); | ||
| } | ||
|
|
There was a problem hiding this comment.
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 unnecessary blank line between methods inside the class.
| @@ -0,0 +1,14 @@ | |||
| package core.basesyntax; | |||
|
|
|||
There was a problem hiding this comment.
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. You have an extra blank line between the package and class declaration and also inside the class body that should be removed.
| package core.basesyntax; | ||
|
|
||
| public class Bulldozer extends Machine { | ||
|
|
There was a problem hiding this comment.
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 unnecessary blank line right after the class declaration.
| package core.basesyntax; | ||
|
|
||
| public class Excavator extends Machine { | ||
|
|
There was a problem hiding this comment.
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. There is an extra blank line between the class declaration and the first method; remove it to comply with the style requirement.
| Machine truck = new Truck(); | ||
| Machine bulldozer = new Bulldozer(); | ||
| Machine excavator = new Excavator(); | ||
|
|
There was a problem hiding this comment.
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. There is an extra empty line inside main between variable declarations and array creation that you can remove.
| @@ -0,0 +1,14 @@ | |||
| package core.basesyntax; | |||
|
|
|||
There was a problem hiding this comment.
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. There is an unnecessary blank line after the package declaration that should be removed.
| package core.basesyntax; | ||
|
|
||
| public class Truck extends Machine { | ||
|
|
There was a problem hiding this comment.
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. There is an extra blank line right after the class declaration.
| public void doWork() { | ||
| System.out.println("A truck started its work"); | ||
| } | ||
|
|
There was a problem hiding this comment.
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. There is an unnecessary blank line between the two methods inside the class.
Added abstract class and 3 inherited classes with methods. Modified main class to call these methods in a loop