Skip to content

Solved machine task#2565

Open
MartaRusanovska wants to merge 2 commits intomate-academy:masterfrom
MartaRusanovska:oop-basic
Open

Solved machine task#2565
MartaRusanovska wants to merge 2 commits intomate-academy:masterfrom
MartaRusanovska:oop-basic

Conversation

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

Great job implementing the class hierarchy and the required methods. The core functionality of your solution is correct. However, some changes are needed before this can be approved.

The main issue is in MainApp.java. You should use the abstract Machine type for your variable references to properly apply the principle of polymorphism, as required by the task. For example, instead of Excavator excavator = new Excavator();, it should be Machine excavator = new Excavator();. This is a key concept for this task and a violation of [CHECKLIST ITEM #3].

Additionally, please remove the redundant empty lines after the class declarations in Machine.java and MainApp.java to adhere to the coding style guidelines [CHECKLIST ITEM #1].

Once you've made these adjustments, your solution will be ready!


✨ 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

Comment on lines +4 to +6

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.

This violates checklist item #1: 'Please don't add redundant empty lines to your code.' The empty lines after the class declaration and between method declarations should be removed.

Comment on lines +6 to +8
Excavator excavator = new Excavator();
Bulldozer bulldozer = new Bulldozer();
Truck truck = new Truck();
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 #3: 'Use abstract references instead of specific ones where possible'. To better leverage polymorphism, you should declare these variables using the abstract Machine type, for example: Machine excavator = new Excavator();. An even more concise approach would be to instantiate the objects directly within the array initialization on the next line.

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! I am approving your solution. You've successfully implemented polymorphism by using the abstract Machine type for your variables, which was the main point from the previous review. The core logic is correct and meets all requirements.

Just a couple of minor points for you to consider for future tasks to make your code even better:

  • In MainApp.java, the printInfo method could be made private since it's only used inside that class. This improves encapsulation [CHECKLIST ITEM #4].
  • Be mindful of extra empty lines after class declarations, like the one in Machine.java, to maintain a consistent coding style [CHECKLIST ITEM #1].

These are just small style and best practice suggestions. Great job completing the task!


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

Footnotes

  1. Rate AI review example

package core.basesyntax;

public abstract class 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 empty line should be removed. As per checklist item #1, redundant empty lines after a class declaration are not allowed. This issue was also mentioned in the previous review.

printInfo(machines);
}

public static void printInfo(Machine[] machines) {
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 method is only used within the MainApp class. To follow the principle of encapsulation, it's better to limit its visibility. Consider using a more restrictive access modifier, which aligns with checklist item #4.

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