-
Notifications
You must be signed in to change notification settings - Fork 1.8k
create new class and method to output #2414
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package core.basesyntax; | ||
public class Bulldozer extends Machine { | ||
@Override | ||
public void doWork() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
|
||
System.out.println("Bulldozer started working"); | ||
} | ||
@Override | ||
public void stopWork() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"); | ||
} | ||
} |
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"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package core.basesyntax; | ||
public abstract class Machine { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
public abstract void doWork(); | ||
public abstract void stopWork(); | ||
} |
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()}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line constructs the array using
Please add the missing |
||
for (Machine machine : machines) { | ||
machine.doWork(); | ||
machine.stopWork(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package core.basesyntax; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: add the
|
||
System.out.println("Truck started working"); | ||
} | ||
@Override | ||
public void stopWork() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: add the |
||
System.out.println("Truck stopped working"); | ||
} | ||
} |
There was a problem hiding this comment.
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.