Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because the core requirements of the task are not implemented yet, so the solution does not demonstrate the needed functionality. In MainApp.java you only print unrelated messages, but the task explicitly requires an abstract Machine class with public abstract void doWork() and public abstract void stopWork(), as well as Truck, Bulldozer, and Excavator classes extending Machine and overriding these methods with informative, English messages indicating which machine is working or stopping. You also need to create a Machine[] in MainApp like Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; and then loop over this array to call doWork() and stopWork() on each element to show polymorphism [CHECKLIST ITEM #3]. Right now, the informative messages are printed directly in MainApp and are not machine-specific, which violates the requirement that each subclass’s doWork()/stopWork() methods should contain these messages [CHECKLIST ITEM #2].
To fix this:
- Add the abstract
Machineclass with the two abstract methods. - Implement
Truck,Bulldozer, andExcavatoras subclasses ofMachineand move the messages into their overriddendoWork()/stopWork()methods (e.g.,"Truck started working","Truck stopped working"). - Update
MainAppso it only creates theMachine[], iterates over it, and callsdoWork()andstopWork()in a loop, without printing unrelated text. Once you make these changes, your solution will fulfill the main functional and checklist requirements and will clearly demonstrate abstract classes and polymorphism.
✨ 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
|
|
||
| public class MainApp { | ||
|
|
||
| public static void main(String[] args) { |
There was a problem hiding this comment.
This violates the task description: "In the MainApp class create a Machine array with Truck, Bulldozer, and Excavator and call methods doWork() and stopWork() in a loop." You need to create a Machine[] (type Machine) containing the three machine instances and iterate over it calling the two methods.
| public class MainApp { | ||
|
|
||
| public static void main(String[] args) { | ||
| System.out.println("Hello world"); |
There was a problem hiding this comment.
This printout does not follow the checklist requirement: "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." Replace these prints with machine-specific messages inside each class's doWork()/stopWork() implementations.
|
|
||
| public static void main(String[] args) { | ||
| System.out.println("Hello world"); | ||
| System.out.println(" I dont understand nothing)))"); |
There was a problem hiding this comment.
Same problem as above: this output is unrelated to the required machine messages and violates the checklist item quoted above. Move messaging into the machine classes and use English, informative messages that indicate the machine type.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because the core task requirements are not yet implemented, so the solution does not demonstrate the required polymorphism. In src/main/java/core/basesyntax/MainApp.java, main only prints a string ("Valid solution") and does not create a Machine[] with Truck, Bulldozer, and Excavator, nor does it loop over them to call doWork() and stopWork() as required. You also need to add an abstract Machine class with public abstract void doWork(); and public abstract void stopWork();, plus the concrete subclasses Truck, Bulldozer, and Excavator that each override these methods with informative English messages like “Truck started working” / “Truck stopped working” that clearly mention the machine type. Then, in MainApp.main, replace the println with something like:
Machine[] machines = { new Truck(), new Bulldozer(), new Excavator() };- iterate with a
for-each loop and callm.doWork(); m.stopWork();to show that behavior is determined by the subclass implementation while using abstractMachinereferences. As a minor point, avoid printing generic or unrelated messages fromMainApp; keep the meaningful output inside thedoWork()/stopWork()methods of each machine. Once you add these classes and updateMainAppaccordingly, your solution will align well with the task and clearly demonstrate inheritance and polymorphism.
✨ 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
|
|
||
| public class MainApp { | ||
|
|
||
| public static void main(String[] args) { |
There was a problem hiding this comment.
This prints unrelated text instead of creating and iterating a Machine[]. This violates the requirement: "In the MainApp class create a Machine array with Truck, Bulldozer, and Excavator and call methods doWork() and stopWork() in a loop." Replace this println with creation of the Machine[] and a loop that calls doWork() and stopWork() on each element so polymorphism is demonstrated .
| public class MainApp { | ||
|
|
||
| public static void main(String[] args) { | ||
| System.out.println("Valid solution"); |
There was a problem hiding this comment.
The message "Valid solution" is not an informative, machine-specific message. This violates the checklist: "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." Move such messages into each subclass's doWork()/stopWork() implementations and avoid printing unrelated text from MainApp .
|
|
||
| public static void main(String[] args) { | ||
| System.out.println("Valid solution"); | ||
| } |
There was a problem hiding this comment.
Main ends without demonstrating polymorphism or using abstract references. This violates: "Use abstract references instead of specific ones where possible" and the implementation detail to iterate over the Machine array and call doWork()/stopWork(). Update main to use Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; for (Machine m : machines) { m.doWork(); m.stopWork(); } so the behavior comes from the subclasses .
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.
fixes to hw-branch
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this task! You have perfectly implemented the abstract Machine class and its subclasses, demonstrating a strong understanding of inheritance. Your MainApp class is a great example of polymorphism in action, correctly using an array of the abstract type to call methods on different objects. The solution is clean, efficient, and meets all the requirements. I am happy to approve your solution, keep up the fantastic work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.