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

Creating machines arrays and loop #2159

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/main/java/core/basesyntax/Bulldozer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package core.basesyntax;

public class Bulldozer extends Machine {
@Override
public void doWork() {
System.out.println("Bulldozer machine started its work.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message in 'System.out.println' should be more informative and indicate the type of machine. Consider specifying that it is a Bulldozer that has started working.

}

@Override
public void stopWork() {

System.out.println("Bulldozer machines stopped working");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message in 'System.out.println' should be more informative and indicate the type of machine. Consider specifying that it is a Bulldozer that has stopped working. Also, there's a typo in the word 'machines', it should be singular 'machine'.


}
}
15 changes: 15 additions & 0 deletions src/main/java/core/basesyntax/Excavator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package core.basesyntax;

public class Excavator extends Machine {
@Override
public void doWork() {
System.out.println("Excavator machine started its work.");

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 be more informative and indicate that the 'Excavator' is working. For example, 'Excavator is starting its work.'

}

@Override
public void stopWork() {

System.out.println("Excavator machines stopped working");

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 be more informative and indicate that the 'Excavator' has stopped working. Also, there is a typographical error, it should be 'Excavator machine' instead of 'Excavator machines'. For example, 'Excavator has stopped its work.'


}
}
9 changes: 9 additions & 0 deletions src/main/java/core/basesyntax/Machine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package core.basesyntax;

public abstract class Machine {

public abstract void doWork();

public abstract void stopWork();

}
15 changes: 15 additions & 0 deletions src/main/java/core/basesyntax/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,19 @@

public class MainApp {

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 class declaration to adhere to the coding standards mentioned in the checklist.

public static void main(String[] args) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the redundant empty line after the method signature as per the checklist guidelines.

Machine[] machines = new Machine[]{
new Bulldozer(), new Truck(), new Excavator()
};

for (Machine machine : machines) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the redundant empty line within the loop to make the code more concise.

machine.doWork();
machine.stopWork();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the redundant empty line after the loop block to follow the checklist's best practices.

}

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 before the closing brace of the method.

}

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the redundant empty line before the closing brace of the class.

16 changes: 16 additions & 0 deletions src/main/java/core/basesyntax/Truck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package core.basesyntax;

public class Truck extends Machine {
@Override
public void doWork() {

System.out.println("Truck machine started its work.");

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 be more informative and indicate that it is a Truck that is working. Consider specifying that explicitly, for example: 'Truck is starting its work.'

}

@Override
public void stopWork() {

System.out.println("Truck machines stopped working");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, the message in the stopWork method should be more informative. It should indicate that it is a Truck that has stopped working. For instance: 'Truck has stopped working.'


}
}
Loading