-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Task2.0 #2187
base: master
Are you sure you want to change the base?
Task2.0 #2187
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.
Great job on implementing the functionality! 🎉 While the code works well, there are a few areas for improvement. Consider using abstract references for better polymorphism, and remember to apply access modifiers to follow encapsulation principles. Also, tidy up by removing redundant empty lines. Addressing these points will enhance your code quality. Keep up the good work and continue learning from these insights!
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
@@ -0,0 +1,13 @@ | |||
package core.basesyntax; | |||
|
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.
Please remove the redundant empty line after the package declaration.
public void doWork() { | ||
System.out.println("Bulldozer started its work."); | ||
} | ||
|
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.
Please remove the redundant empty line after the method.
public class Excavator extends Machine { | ||
@Override | ||
public void doWork() { | ||
System.out.println("Excavator started its work."); |
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.
The message in the doWork
method should indicate the type of Machine
that is working, which is correct here as it mentions Excavator
.
|
||
@Override | ||
public void stopWork() { | ||
System.out.println("Excavator stopped working."); |
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.
The message in the stopWork
method should indicate the type of Machine
that is working, which is correct here as it mentions Excavator
.
@@ -0,0 +1,7 @@ | |||
package core.basesyntax; | |||
|
|||
abstract class Machine { |
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.
Consider using access modifiers for the class declaration to follow the encapsulation principle. For example, you might want to make this class public if it is intended to be accessed from outside its package.
@@ -1,5 +1,11 @@ | |||
package core.basesyntax; | |||
|
|||
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.
Consider using abstract references instead of specific ones where possible. According to the checklist, it's better to use Machine
as the type for the elements in the machines
array to allow for polymorphism.
public class Truck extends Machine { | ||
@Override | ||
public void doWork() { | ||
System.out.println("Truck started its work."); |
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.
The message should indicate what type of Machine is working right now. The current message 'Truck started its work.' is informative and correctly indicates the type of Machine.
|
||
@Override | ||
public void stopWork() { | ||
System.out.println("Truck stopped working."); |
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.
The message should indicate what type of Machine is working right now. The current message 'Truck stopped working.' is informative and correctly indicates the type of Machine.
No description provided.