Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 {
@Override
public void doWork() {
System.out.println("doWork bulldozer");

Choose a reason for hiding this comment

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

This violates checklist item #2: 'Write informative messages in methods'. The message should be a full sentence that clearly states the machine has started its work, for example, Bulldozer started its work.

}

@Override
public void stopWork() {
System.out.println("stopWork bulldozer");

Choose a reason for hiding this comment

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

This violates checklist item #2: 'Write informative messages in methods'. The message should be a full sentence that clearly states the machine has stopped its work, for example, Bulldozer stopped its work.

}
}
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 {
@Override
public void doWork() {
System.out.println("doWork excavator");

Choose a reason for hiding this comment

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

This violates checklist item #2: 'Write informative messages in methods.' The message should clearly state that the excavator has started its work, for example: Excavator started its work.

}

@Override
public void stopWork() {
System.out.println("stopWork excavator");

Choose a reason for hiding this comment

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

This violates checklist item #2: 'Write informative messages in methods.' The message should clearly state that the excavator has stopped working, for example: Excavator stopped working.

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

public abstract class Machine {
private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

Choose a reason for hiding this comment

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

The name field and its getter/setter methods are not required by the task description. The subclasses don't use this field to print their messages, making this code unnecessary for the current task. It's good practice to only add code that is needed to fulfill the requirements.


public abstract void doWork();

public abstract void stopWork();

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

public class MainApp {
public static void main(String[] args) {
Machine truck = new Truck();
truck.setName("truck");

Machine bulldozer = new Bulldozer();
bulldozer.setName("bulldozer");

Machine excavator = new Excavator();
excavator.setName("excavator");

Choose a reason for hiding this comment

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

These calls to setName() are not required by the task, and the name property is never used to generate the output messages. The messages are hardcoded in the doWork() and stopWork() methods of each specific machine class. You can remove the name field from the Machine class and these setName() calls to simplify the solution.


Machine [] machines = new Machine[] {truck, bulldozer, excavator};
for (Machine machine : machines) {
printInfo(machine);
}
}

public static void printInfo(Machine machine) {
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 {
@Override
public void doWork() {
System.out.println("doWork truck");

Choose a reason for hiding this comment

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

This violates checklist item #2: 'Write informative messages in methods'. The message should be a more descriptive sentence, such as 'Truck started its work', to clearly communicate the action.

}

@Override
public void stopWork() {
System.out.println("stopWork truck");

Choose a reason for hiding this comment

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

This violates checklist item #2: 'Write informative messages in methods'. A more informative message would be a full sentence like 'Truck stopped its work'.

}
}