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

First solution #2161

Open
wants to merge 1 commit 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
13 changes: 13 additions & 0 deletions src/main/java/core/basesyntax/Bulldozer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package core.basesyntax;

public class Bulldozer extends Machine{

Choose a reason for hiding this comment

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

There should be a space between the class name and the opening brace to conform with Java coding standards.

@Override
public void doWork() {
System.out.println("Bulldozer started 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 indicate the type of machine, which you have correctly done, but consider making it more informative. For example: 'Bulldozer is starting its work'.

}

@Override
public void stopWork() {
System.out.println("Bulldozer stopped working");

Choose a reason for hiding this comment

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

Similarly, the stop message could be more informative, e.g., 'Bulldozer has finished its work and is shutting down'.

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

public class Excavator extends Machine{

Choose a reason for hiding this comment

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

There should be a space between the class name Machine and the curly brace { to adhere to Java code style conventions.

@Override
public void doWork() {
System.out.println("Excavator started 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 that it is an Excavator that has started working, as per the checklist's requirement to use informative messages.

}

@Override
public void stopWork() {
System.out.println("Excavator 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 that it is an Excavator that has stopped working, as per the checklist's requirement to use informative messages.

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

public abstract class Machine {
public abstract void doWork();
public abstract void stopWork();
}
7 changes: 7 additions & 0 deletions src/main/java/core/basesyntax/MainApp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package core.basesyntax;

public class MainApp {
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.

Please ensure that there is a space between the closing parenthesis of the method signature and the opening curly brace { to adhere to Java code conventions.

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

for (Machine machine : machines){

Choose a reason for hiding this comment

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

There should be a space after for and before the opening parenthesis ( to maintain consistent code style.

machine.doWork();
machine.stopWork();
}
}
}
13 changes: 13 additions & 0 deletions src/main/java/core/basesyntax/Truck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package core.basesyntax;

public class Truck extends Machine{

Choose a reason for hiding this comment

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

There is a missing space between the class name 'Machine' and the opening brace '{'. It should be extends Machine { to follow Java code conventions.

@Override
public void doWork() {
System.out.println("Truck started 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 System.out.println should be more informative. Mention that it is a Truck that has started working, to provide clarity in the output.

}

@Override
public void stopWork() {
System.out.println("Truck stopped working");

Choose a reason for hiding this comment

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

Similarly, the stop message should be more informative. Indicate that it is a Truck that has stopped working.

}
}
Loading