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

Choose a reason for hiding this comment

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

Missing required project elements: the abstract Machine class, and the other concrete classes (Truck and Excavator), plus the MainApp entry point are not present in the submitted files. This violates checklist item 1.1: "Create an abstract class named Machine that declares two abstract methods: - public abstract void doWork(); - public abstract void stopWork();" and checklist item 1.2: "Create three concrete classes: Truck, Bulldozer, and Excavator that inherit from Machine." It also violates checklist item 1.5: "Create a MainApp class with a main method that: - Creates an array (or collection) of Machine references containing instances of Truck, Bulldozer, and Excavator. - Iterates over the array and calls doWork() and stopWork() for each element." Additionally, checklist item 3.2 states: "In MainApp, create instances with abstract references, e.g., Machine m = new Truck(); and store them in a Machine[] (or similar). Avoid using concrete-type references like Truck t = new Truck(); when not necessary." Please add these missing files so I can fully verify the task requirements and polymorphism behavior.

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

Choose a reason for hiding this comment

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

Suggestion: add the @OverRide annotation above doWork(). While not strictly required by the checklist, it makes the overriding intent explicit and enables compiler checks. Example:

@Override
public void doWork() { ... }

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

Choose a reason for hiding this comment

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

Suggestion: add the @OverRide annotation above stopWork() as well, for the same reasons as above.

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

Choose a reason for hiding this comment

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

The project currently lacks the required concrete subclasses and the main application. This violates the checklist item: "Create three concrete classes: Truck, Bulldozer, and Excavator that inherit from Machine (extend Machine)." and also violates: "Create a MainApp class with a main method that: - Creates an array (or collection) of Machine references containing instances of Truck, Bulldozer, and Excavator. - Iterates over the array and calls doWork() and stopWork() for each element." Please add Truck, Bulldozer, Excavator classes (each extending Machine and overriding the methods with informative messages) and a MainApp with a main method that stores them in a Machine[] and invokes doWork() / stopWork().

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

public class MainApp {

}
public static void main(String[] args) {
// All executable code goes inside this method
Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()};

Choose a reason for hiding this comment

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

This line constructs the array using new Truck() and new Excavator() but those classes (and the abstract Machine type if not present) appear not to be provided. Without the abstract Machine class and the concrete Truck and Excavator classes this file will not compile. This violates the following checklist items (quoted exactly):

  • "Create an abstract class named Machine that declares two abstract methods: - public abstract void doWork(); - public abstract void stopWork();" (checklist item 1.1)
  • "Create three concrete classes: Truck, Bulldozer, and Excavator that inherit from Machine." (checklist item 1.2)
  • "Create a MainApp class with a main method that: - Creates an array (or collection) of Machine references containing instances of Truck, Bulldozer, and Excavator. - Iterates over the array and calls doWork() and stopWork() for each element." (checklist item 1.5)
  • "In MainApp, create instances with abstract references, e.g., Machine m = new Truck(); and store them in a Machine[] (or similar). Avoid using concrete-type references like Truck t = new Truck(); when not necessary." (checklist item 3.2)

Please add the missing Machine, Truck, and Excavator classes (implement doWork()/stopWork() in each) so the project can compile and I can verify the rest of the checklist.

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

Choose a reason for hiding this comment

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

Missing required project elements. The project must include an abstract Machine class and the other classes and entry point required by the task. This violates checklist item 1.1: "Create an abstract class named Machine that declares two abstract methods: - public abstract void doWork(); - public abstract void stopWork();" and checklist item 1.2: "Create three concrete classes: Truck, Bulldozer, and Excavator that inherit from Machine." It also violates checklist item 1.5: "Create a MainApp class with a main method that: - Creates an array (or collection) of Machine references containing instances of Truck, Bulldozer, and Excavator. - Iterates over the array and calls doWork() and stopWork() for each element." Additionally, checklist item 3.2 requires: "In MainApp, create instances with abstract references, e.g., Machine m = new Truck(); and store them in a Machine[] (or similar). Avoid using concrete-type references like Truck t = new Truck(); when not necessary." Please add Machine, Excavator, and MainApp files so the full task can be verified.

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

Choose a reason for hiding this comment

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

Suggestion: add the @Override annotation above doWork() to make the overriding explicit and enable compiler checks. Example:

@Override
public void doWork() { ... }

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

Choose a reason for hiding this comment

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

Suggestion: add the @Override annotation above stopWork() as well. This is recommended for clarity and compile-time verification.

System.out.println("Truck stopped working");
}
}
Loading