-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Implement machine hierarchy with Truck, Bulldozer, and Excavator classes #2462
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 2 commits
5e971b5
ec013ff
242ff5f
31e58c9
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,14 @@ | ||
| 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. This violates checklist item #1: "Avoid redundant empty lines after class declarations and method signatures; keep formatting compact." Remove the redundant blank line after the 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 violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the empty line after the package declaration so the file begins directly with the class declaration. |
||
| public class Bulldozer extends Machine { | ||
|
|
||
|
||
| @Override | ||
| public void doWork() { | ||
| System.out.println("Bulldozer started working"); | ||
| } | ||
|
|
||
|
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 violates checklist item #1: "Avoid redundant empty lines after class declarations and method signatures; keep formatting compact." Remove the blank line between the first method block and the next 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 violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the empty line between the two methods (after |
||
| @Override | ||
| public void stopWork() { | ||
| System.out.println("Bulldozer stopped to working"); | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| 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. There are redundant empty lines in this file (for example this blank line after the package). This goes against the style requirement: "Avoid redundant empty lines after class declarations and method signatures; keep formatting compact. [CHECKLIST ITEM #1]". Remove unnecessary blank lines so the file is more compact. 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 violates checklist item #1: "Please don't add redundant empty lines to your code." Remove the blank line after the package declaration so the |
||
| public class Excavator extends Machine { | ||
|
|
||
|
||
| @Override | ||
| public void doWork() { | ||
| System.out.println("Excavator started to working."); | ||
|
||
| } | ||
|
|
||
|
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. There is an unnecessary empty line between the end of the first method and the 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. Another redundant blank line inside the class. Please remove to satisfy: "Avoid redundant empty lines after class declarations and method signatures; keep formatting compact. [CHECKLIST ITEM #1]". 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 violates checklist item #1: "Please don't add redundant empty lines to your code." Remove the unnecessary blank line between the |
||
| @Override | ||
| public void stopWork() { | ||
| System.out.println("Excavator stopped to working."); | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| 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. This file contains a redundant blank line immediately after the package statement. This violates checklist item #1: "Avoid redundant empty lines after class declarations and method signatures; keep formatting compact. [CHECKLIST ITEM #1]" Remove the empty line at line 2 so the package declaration is followed directly by the class declaration or imports (if any). 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 violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the redundant blank line after the package statement so the package is immediately followed by the class declaration. |
||
| public abstract class Machine { | ||
|
|
||
|
||
| public abstract 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. There is an unnecessary blank line between the two abstract method declarations. This violates checklist item #1: "Avoid redundant empty lines after class declarations and method signatures; keep formatting compact. [CHECKLIST ITEM #1]" Remove the empty line at line 6 so the method declarations are adjacent and the class remains compact. 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 violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the redundant blank line between the two method declarations so the methods follow each other without extra empty lines. |
||
| public abstract void stopWork(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| package core.basesyntax; | ||
|
|
||
| public class MainApp { | ||
| public static void main(String[] args) { | ||
| Machine[] machines = {new Truck(), new Bulldozer(), new Excavator()}; | ||
|
|
||
| for (Machine machine : machines) { | ||
| machine.doWork(); | ||
| } | ||
|
|
||
| System.out.println("---All machines finished their tasks---"); | ||
|
|
||
| for (Machine machine : machines) { | ||
| machine.stopWork(); | ||
| } | ||
|
Comment on lines
7
to
10
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 does not follow the task instruction to call both methods per element. The description requires: "In the Currently you call This ensures each machine has both methods invoked in the same iteration, as required.
Comment on lines
7
to
10
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 current code iterates twice: one loop calls This change ensures the behavior required by the task description and preserves polymorphic usage of |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| 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. This violates the checklist item: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the unnecessary blank line after the package declaration. It's redundant and not needed (line 2). 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 violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the blank line after the package statement so the package is immediately followed by the class declaration. |
||
| public class Truck extends Machine { | ||
|
|
||
|
||
| @Override | ||
| public void doWork() { | ||
| System.out.println("Truck started working."); | ||
| } | ||
|
|
||
|
Comment on lines
2
to
8
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 violates checklist item #1: "Please don't add redundant empty lines to your code." Remove the blank lines after the package declaration and after the class/method signatures to keep the formatting compact (specifically remove the empty lines at lines 2, 4, and 9). 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 violates checklist item #1: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove the blank line between the two method blocks so the methods are adjacent without an extra empty line. |
||
| @Override | ||
| public void stopWork() { | ||
| 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.
This line is a redundant empty line after the
package/before the class 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." Remove this extra blank line so the class declaration immediately follows the package statement. See checklist for guidance .