Skip to content

added psvm method#2547

Open
DmitriyJava wants to merge 5 commits intomate-academy:masterfrom
DmitriyJava:hw-1solution
Open

added psvm method#2547
DmitriyJava wants to merge 5 commits intomate-academy:masterfrom
DmitriyJava:hw-1solution

Conversation

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

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 Machine class with the two abstract methods.
  • Implement Truck, Bulldozer, and Excavator as subclasses of Machine and move the messages into their overridden doWork()/stopWork() methods (e.g., "Truck started working", "Truck stopped working").
  • Update MainApp so it only creates the Machine[], iterates over it, and calls doWork() and stopWork() 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


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 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");
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 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)))");
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 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.

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 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 call m.doWork(); m.stopWork(); to show that behavior is determined by the subclass implementation while using abstract Machine references. As a minor point, avoid printing generic or unrelated messages from MainApp; keep the meaningful output inside the doWork()/stopWork() methods of each machine. Once you add these classes and update MainApp accordingly, 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


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 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");
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 "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");
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 .

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.

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.

@DmitriyJava DmitriyJava marked this pull request as draft March 11, 2026 22:19
@DmitriyJava DmitriyJava marked this pull request as ready for review March 11, 2026 23:02
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

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! ✨

Footnotes

  1. Rate AI review example

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