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
12 changes: 12 additions & 0 deletions src/test/java/core/basesyntax/Buldozer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package core.basesyntax;

public class Buldozer extends Machine{
@Override
public void doWork(){
System.out.println(getClass().getSimpleName() + " started working...");
}
@Override
public void stopWork(){
System.out.println(getClass().getSimpleName() + " stopped working...");
}
}
12 changes: 12 additions & 0 deletions src/test/java/core/basesyntax/Excavator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package core.basesyntax;

public class Excavator extends Machine{
@Override
public void doWork(){
System.out.println(getClass().getSimpleName() + " started working...");
Copy link

@fetis-off fetis-off Feb 8, 2026

Choose a reason for hiding this comment

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

Suggested change
System.out.println(getClass().getSimpleName() + " started working...");
System.out.println("Excavator started working...");

I am wondering about this reflection using here. Please, keep it simple in all classes
Using this method getClass().getSimpleName() is good for debugging and logging, when you don't know about which class is executing at some moment.

}
@Override
public void stopWork(){
System.out.println(getClass().getSimpleName() + " stopped working...");
}
}
7 changes: 7 additions & 0 deletions src/test/java/core/basesyntax/Machine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package core.basesyntax;

public abstract class Machine {
public abstract void doWork();
public abstract void stopWork();

}
13 changes: 12 additions & 1 deletion src/test/java/core/basesyntax/MainAppTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
package core.basesyntax;

public class MainAppTest {
public static void main(String[] args) {
Machine [] machines = new Machine[3];
machines[0] = new Truck();
machines[1] = new Buldozer();
machines[2] = new Excavator();

}
for (Machine machine : machines) {
machine.doWork();
machine.stopWork();
}
}

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

public class Truck extends Machine{
@Override
public void doWork(){
System.out.println(getClass().getSimpleName() + " started working...");
}
@Override
public void stopWork(){
System.out.println(getClass().getSimpleName() + " stopped working...");
}
}