Created classes and main task has passed mvn clean package#2592
Created classes and main task has passed mvn clean package#2592acidden wants to merge 3 commits into
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation successfully fulfills all core functional requirements for the OOP inheritance task. The abstract Machine class with its three subclasses (Truck, Bulldozer, Excavator) is correctly structured, polymorphism is properly implemented with the Machine array, and all method overrides output informative English messages as required. The code compiles and runs correctly with expected output. While there are some style improvements that could be made - such as removing redundant empty lines (checklist item #1) and changing the Machine constructor from public to protected (checklist item #4) - these are non-blocking style violations rather than critical functional issues. The linter will provide feedback on formatting, so focus on understanding why the constructor visibility matters for abstract classes as a learning opportunity. Well done on meeting all the core requirements!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| @@ -1,5 +1,12 @@ | |||
| package core.basesyntax; | |||
|
|
|||
There was a problem hiding this comment.
Redundant empty line after package declaration - violates checklist item #1
| package core.basesyntax; | ||
|
|
||
| public class MainApp { | ||
| public static void main(String[] args) { |
There was a problem hiding this comment.
Redundant empty line after class declaration - violates checklist item #1
|
|
||
| Machine[] machines = new Machine[]{new Truck(), new Bulldozer(), new Excavator()}; | ||
| for (Machine machine : machines) { | ||
| machine.doWork(); |
There was a problem hiding this comment.
Redundant empty line after method body - violates checklist item #1
| Machine[] machines = new Machine[]{new Truck(), new Bulldozer(), new Excavator()}; | ||
| for (Machine machine : machines) { | ||
| machine.doWork(); | ||
| machine.stopWork(); |
There was a problem hiding this comment.
Redundant empty line before second method - violates checklist item #1
| package core.basesyntax; | ||
|
|
||
| public class Bulldozer extends Machine { | ||
|
|
There was a problem hiding this comment.
Redundant empty line after class declaration - violates checklist item #1
|
|
||
| public class Excavator extends Machine { | ||
|
|
||
| @Override |
There was a problem hiding this comment.
The constructor should be protected instead of public. Abstract classes cannot be instantiated directly, so a public constructor is misleading. Using protected is the standard practice for abstract class constructors.
| @@ -0,0 +1,14 @@ | |||
| package core.basesyntax; | |||
|
|
|||
There was a problem hiding this comment.
Redundant empty line after package declaration - violates checklist item #1
| package core.basesyntax; | ||
|
|
||
| public class Truck extends Machine { | ||
|
|
There was a problem hiding this comment.
Redundant empty line after class declaration - violates checklist item #1
| @Override | ||
| public void doWork() { | ||
| System.out.println("Truck starting working"); | ||
| } |
There was a problem hiding this comment.
Redundant empty line after method body - violates checklist item #1
| public void doWork() { | ||
| System.out.println("Truck starting working"); | ||
| } | ||
|
|
There was a problem hiding this comment.
Redundant empty line before second method - violates checklist item #1
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]
If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation successfully fulfills all core functional requirements for the OOP inheritance task. The abstract Machine class with its three subclasses (Truck, Bulldozer, Excavator) is correctly structured, polymorphism is properly implemented with the Machine array in MainApp, and all method overrides output informative English messages as expected. The issues identified in the review are minor style concerns rather than functional blockers. The redundant empty lines mentioned in Machine.java and Truck.java are formatting issues that don't affect code functionality. Similarly, the constructor visibility suggestions (changing public to protected for abstract class constructors) represent better encapsulation practices but don't prevent the code from working correctly. The code compiles and runs as intended with proper output. Your solution demonstrates a solid understanding of Java inheritance, abstract classes, and polymorphism.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| @@ -0,0 +1,11 @@ | |||
| package core.basesyntax; | |||
|
|
|||
There was a problem hiding this comment.
Checklist item #1 violation: Redundant empty line after package declaration. Remove this empty line.
| package core.basesyntax; | ||
|
|
||
| public abstract class Machine { | ||
|
|
There was a problem hiding this comment.
Checklist item #1 violation: Redundant empty line after class declaration. Remove this empty line.
| public Machine() { | ||
| } | ||
|
|
||
| public abstract void doWork(); |
There was a problem hiding this comment.
Checklist item #1 violation: Redundant empty line after method body. Remove this empty line.
| } | ||
|
|
||
| public abstract void doWork(); | ||
|
|
| public class MainApp { | ||
|
|
||
| public static void main(String[] args) { | ||
| Machine[] machines = new Machine[]{new Truck(), new Bulldozer(), new Excavator()}; |
There was a problem hiding this comment.
The Machine constructor is public, but for an abstract class, consider using protected instead. This better reflects that Machine is an abstraction only meant to be extended by subclasses, not instantiated directly.
|
|
||
| public class Excavator extends Machine { | ||
|
|
||
| @Override |
There was a problem hiding this comment.
Checklist item #4: This constructor should be protected instead of public. Abstract class constructors are only meant to be called by subclasses during instantiation, so protected better reflects this intent and improves encapsulation.
| @@ -0,0 +1,14 @@ | |||
| package core.basesyntax; | |||
|
|
|||
There was a problem hiding this comment.
Checklist item #1 violation: Redundant empty line after package declaration. Remove this empty line.
| package core.basesyntax; | ||
|
|
||
| public class Truck extends Machine { | ||
|
|
There was a problem hiding this comment.
Checklist item #1 violation: Redundant empty line after class declaration. Remove this empty line.
| @Override | ||
| public void doWork() { | ||
| System.out.println("Truck starting working"); | ||
| } |
There was a problem hiding this comment.
Checklist item #1 violation: Redundant empty line after method body. Remove this empty line.
| public void doWork() { | ||
| System.out.println("Truck starting working"); | ||
| } | ||
|
|
No description provided.