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

Choose a reason for hiding this comment

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

This file has a redundant empty line after the package declaration. The checklist explicitly says: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Consider removing this blank line to follow the project's checklist and keep code compact.

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

Choose a reason for hiding this comment

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

This file has an unnecessary empty line between the two method blocks. The checklist states: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove this blank line to comply with the checklist.

@Override
public void stopWork() {
System.out.println("Bulldozer stopped working.");
}
}
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("Excavator started its work.");
}

@Override
public void stopWork() {
System.out.println("Excavator stopped working.");
}
}
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();
}
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
Machine[] machines = new Machine[] {
new Truck(),
new Bulldozer(),
new Excavator()
};

System.out.println("--- STARTING WORK CYCLE ---");
// Цикл для виклику doWork()
for (Machine machine : machines) {
machine.doWork();
}

System.out.println("\n--- STOPPING WORK CYCLE ---");
// Цикл для виклику stopWork()
for (Machine machine : machines) {
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;

Choose a reason for hiding this comment

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

This line is a redundant empty line after the package declaration. The checklist says: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Consider removing this blank line to follow the project's checklist.

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

Choose a reason for hiding this comment

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

This line is an unnecessary empty line between method blocks. The checklist says: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove this blank line to comply with the checklist.

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