-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Creating machines arrays and loop #2159
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,15 @@ | ||
package core.basesyntax; | ||
|
||
public class Bulldozer extends Machine { | ||
@Override | ||
public void doWork() { | ||
System.out.println("Bulldozer machine started its work."); | ||
} | ||
|
||
@Override | ||
public void stopWork() { | ||
|
||
System.out.println("Bulldozer machines stopped 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. The message in 'System.out.println' should be more informative and indicate the type of machine. Consider specifying that it is a Bulldozer that has stopped working. Also, there's a typo in the word 'machines', it should be singular 'machine'. |
||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package core.basesyntax; | ||
|
||
public class Excavator extends Machine { | ||
@Override | ||
public void doWork() { | ||
System.out.println("Excavator machine started its work."); | ||
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 message in the 'doWork' method should be more informative and indicate that the 'Excavator' is working. For example, 'Excavator is starting its work.' |
||
} | ||
|
||
@Override | ||
public void stopWork() { | ||
|
||
System.out.println("Excavator machines stopped 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. The message in the 'stopWork' method should be more informative and indicate that the 'Excavator' has stopped working. Also, there is a typographical error, it should be 'Excavator machine' instead of 'Excavator machines'. For example, 'Excavator has stopped its work.' |
||
|
||
} | ||
} |
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(); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,19 @@ | |
|
||
public class MainApp { | ||
|
||
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. Please remove the redundant empty line after the class declaration to adhere to the coding standards mentioned in the checklist. |
||
public static void main(String[] args) { | ||
|
||
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. Remove the redundant empty line after the method signature as per the checklist guidelines. |
||
Machine[] machines = new Machine[]{ | ||
new Bulldozer(), new Truck(), new Excavator() | ||
}; | ||
|
||
for (Machine machine : machines) { | ||
|
||
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. Remove the redundant empty line within the loop to make the code more concise. |
||
machine.doWork(); | ||
machine.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. Remove the redundant empty line after the loop block to follow the checklist's best practices. |
||
} | ||
|
||
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. Please remove the redundant empty line before the closing brace of the method. |
||
} | ||
|
||
} | ||
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. Remove the redundant empty line before the closing brace of the class. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package core.basesyntax; | ||
|
||
public class Truck extends Machine { | ||
@Override | ||
public void doWork() { | ||
|
||
System.out.println("Truck machine started its work."); | ||
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 message in the |
||
} | ||
|
||
@Override | ||
public void stopWork() { | ||
|
||
System.out.println("Truck machines stopped 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. Similarly, the message in the |
||
|
||
} | ||
} |
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.
The message in 'System.out.println' should be more informative and indicate the type of machine. Consider specifying that it is a Bulldozer that has started working.