-
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
gii #2177
base: master
Are you sure you want to change the base?
gii #2177
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 your code so far! 👍 However, there are a few improvements that need to be made before we can approve this pull request. The methods doWork()
and stopWork()
in the Machine
class need to be declared as abstract and implemented in the subclasses. This will ensure that each machine behaves correctly. Also, consider using enhanced for loop for better readability and error prevention. Keep up the good work and happy coding! 😄
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
public 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.
The doWork()
method currently has no functionality. Since this is an abstract class, this method should be declared as abstract. This will enforce that any class extending Machine
will have to provide an implementation for this method.
public void stopWork() { | ||
|
||
} |
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 stopWork()
method currently has no functionality. Since this is an abstract class, this method should be declared as abstract. This will enforce that any class extending Machine
will have to provide an implementation for this method.
@@ -1,5 +1,14 @@ | |||
package core.basesyntax; | |||
|
|||
public class MainApp { | |||
public static void main(String[] ggss) { | |||
|
|||
Machine[] machines = {new Truck(), new Excavator(), 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.
Consider using abstract references instead of specific ones. This will allow you to use polymorphism in your code. For example, instead of Machine[] machines = {new Truck(), new Excavator(), new Bulldozer()};
, you can use Machine[] machines = {new Machine(), new Machine(), new Machine()};
.
for(int i = 0; i < machines.length; i++) { | ||
machines[i].doWork(); | ||
machines[i].stopWork(); | ||
} |
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.
It's recommended to use the enhanced for loop when iterating over an array or a collection. It's more readable and less error-prone. Here is how you can do it: for (Machine machine : machines) { machine.doWork(); machine.stopWork(); }
.
No description provided.