-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Machine classes #2457
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?
Machine classes #2457
Conversation
Add Truck, Bulldozer and Excavator classes extending Machine Implement MainApp with array of machines and looped work calls
Add Truck, Bulldozer and Excavator classes extending Machine Implement MainApp with array of machines and looped work calls
mateacademy-ai-mentor
left a comment
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
Your solution meets the functional requirements: the abstract Machine defines doWork() and stopWork(), each concrete class (Truck, Bulldozer, Excavator) overrides them with English messages, and MainApp iterates over a Machine[] calling both methods. Well done on using polymorphism correctly and keeping method signatures public.
Minor style notes to address next time (non-blocking):
- [CHECKLIST] Remove redundant empty lines:
Machine.java: delete the blank line between the two abstract method declarations.MainApp.javaline 6: remove the extra blank line insidemain.Truck.java: remove the blank line betweendoWork()and the@OverrideofstopWork().
- Optional: keep spacing consistent in array literals (e.g., add a space after commas).
Overall, nice work—functionality is correct and clear. Keep polishing formatting to align fully with the checklist.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
|
|
||
| public abstract class Machine { | ||
| public abstract void doWork(); | ||
|
|
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: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the blank line between the two abstract method declarations so there is no empty line after the doWork() signature. See the checklist guidance for this rule.
| public class MainApp { | ||
| public static void main(String[] args) { | ||
| Machine[] machines = {new Truck(),new Bulldozer(), 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: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the blank line at line 6 to avoid redundant empty lines and match the style guidance.
| public void doWork() { | ||
| System.out.println("Truck started"); | ||
| } | ||
|
|
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: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the blank line between the doWork() method and the @Override for stopWork() so there are no redundant empty lines in the class.
Create abstract Machine class with doWork() and stopWork() methods
Add Truck, Bulldozer and Excavator classes extending Machine
Implement MainApp with array of machines and looped work calls