-
Notifications
You must be signed in to change notification settings - Fork 1.8k
done #2413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
done #2413
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
Decision: REQUEST_CHANGES
You’ve implemented the class hierarchy and behavior well—Machine
, Truck
, Bulldozer
, and Excavator
all look correct and the loop over the machines works. However, there is a critical checklist violation in MainApp.java
related to polymorphism that needs to be fixed before approval.
Critical issues to fix (blockers):
- Use abstract references instead of specific ones.
- Location:
src/main/java/core/basesyntax/MainApp.java
- Likely lines near where variables are created (e.g., around the declarations for
truck
,bulldozer
,excavator
). - Issue: Variables are declared with concrete types (
Truck
,Bulldozer
,Excavator
) instead of the abstract typeMachine
, violating the checklist requirement. - Why it’s wrong: The task explicitly requires programming to the abstraction to demonstrate polymorphism. Declaring them as
Machine
ensures your code relies on the abstract contract rather than concrete implementations. - How to fix: Change declarations to use the abstract type, for example:
Machine truck = new Truck();
Machine bulldozer = new Bulldozer();
Machine excavator = new Excavator();
- Also ensure any arrays or collections are of type
Machine[]
or similar (you already iterate an array ofMachine
, which is good).
- Location:
Minor notes (non-blocking):
- Everything else (messages, access modifiers, overrides) looks solid and clean.
Once you switch those variable declarations to Machine
, you’ll fully meet the checklist and requirements. Nice work overall—this is a quick fix to align perfectly with polymorphism best practices.
✨ 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) { | ||
Truck truck = new Truck(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates checklist item: "Use abstract references instead of specific ones." The variables truck
, bulldozer
, and excavator
should be declared as Machine truck = new Truck();
, etc., to fully utilize polymorphism and satisfy the requirements.
public class MainApp { | ||
public static void main(String[] args) { | ||
Truck truck = new Truck(); | ||
Bulldozer bulldozer = new Bulldozer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates checklist item: "Use abstract references instead of specific ones." The variables truck
, bulldozer
, and excavator
should be declared as Machine bulldozer = new Bulldozer();
, etc., to fully utilize polymorphism and satisfy the requirements.
public static void main(String[] args) { | ||
Truck truck = new Truck(); | ||
Bulldozer bulldozer = new Bulldozer(); | ||
Excavator excavator = new Excavator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates checklist item: "Use abstract references instead of specific ones." The variables truck
, bulldozer
, and excavator
should be declared as Machine excavator = new Excavator();
, etc., to fully utilize polymorphism and satisfy the requirements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
Great work! Your implementation fully meets the task requirements and checklist:
- The abstract class
Machine
correctly declarespublic abstract void doWork()
andpublic abstract void stopWork()
. Truck
,Bulldozer
, andExcavator
extendMachine
and properly override both methods with clear, English messages identifying the machine type.- In
MainApp
, you useMachine
references, store them in aMachine[]
, and iterate to call both methods on each instance, demonstrating polymorphism as required. - Access modifiers are appropriate, and there are no redundant empty lines.
No critical issues found; functionality and requirements are fully satisfied. Nice job applying abstraction and polymorphism cleanly. Keep it up!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.