Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

gii #2177

wants to merge 5 commits into from

Conversation

FaisByan
Copy link

No description provided.

Copy link

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

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! ✨

Comment on lines 4 to 6
public void doWork(){

}

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.

Comment on lines 7 to 9
public void stopWork() {

}

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()};

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()};.

Comment on lines 8 to 11
for(int i = 0; i < machines.length; i++) {
machines[i].doWork();
machines[i].stopWork();
}

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(); }.

@FaisByan FaisByan closed this Oct 11, 2024
@FaisByan FaisByan reopened this Oct 11, 2024
@FaisByan FaisByan closed this Oct 11, 2024
@FaisByan FaisByan reopened this Oct 11, 2024
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.

3 participants