-
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
created classes, overridden abstract methods, and created an array of… #2119
base: master
Are you sure you want to change the base?
Changes from 1 commit
47e3b25
11ab46d
b0bae41
29109a8
bde023b
77d4451
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; | ||
|
||
public class Bulldozer extends 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. There should not be an empty line after the class declaration. Please remove the redundant empty line. 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 should not be an empty line after the class declaration. Please remove the redundant empty line to comply with the coding style guidelines. |
||
|
||
@Override | ||
public void doWork() { | ||
System.out.println("the bulldozer started it`s 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 should be more informative and indicate that it is a Bulldozer that is working. For example: 'Bulldozer 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("the bulldozer stopped it`s 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 should be more informative and indicate that it is a Bulldozer that has stopped working. For example: 'Bulldozer stopped its work.' Also, use the correct possessive form 'its' instead of 'it`s'. 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 |
||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,15 @@ | ||||||||
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.
Suggested change
|
||||||||
|
||||||||
public class Excavator extends Machine { | ||||||||
|
||||||||
@Override | ||||||||
public void doWork() { | ||||||||
System.out.println("the excavator started it`s 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 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 should be more informative and indicate that it is an Excavator that is working. Consider rephrasing to something like 'Excavator started working.' |
||||||||
|
||||||||
} | ||||||||
|
||||||||
@Override | ||||||||
public void stopWork() { | ||||||||
System.out.println("the excavator stopped it`s 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. Similarly, the message in 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. Use proper apostrophes in 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 stop message should be more informative. It should clearly state that it is an Excavator that has stopped working. For example, 'Excavator stopped working.' |
||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,6 @@ | ||||||||
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.
Suggested change
|
||||||||
|
||||||||
public abstract class Machine { | ||||||||
public abstract void doWork(); | ||||||||
public abstract void stopWork(); | ||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
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. revert empty line |
||
public class MainApp { | ||
public static void main(String[] args) { | ||
Machine truck = new Truck(); | ||
Machine bulldozer = new Bulldozer(); | ||
Machine excavator = 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. Use abstract references instead of specific ones where possible. This allows for more flexible code that can take advantage of polymorphism. For example, consider using 'Vehicle truck = new Truck();' if 'Vehicle' is an appropriate abstract class or interface in your codebase. |
||
Machine[] machine = {truck, bulldozer, 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. The array name |
||
|
||
for (Machine m : machine) { | ||
m.doWork(); | ||
m.stopWork(); | ||
System.out.println(); | ||
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. Redundant empty line after the method call. According to the checklist, please don't add redundant empty lines to your code. It's better to remove this line to make the code cleaner. |
||
} | ||
} | ||
} |
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.
Suggested change
|
||||||||
|
||||||||
public class Truck extends 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. There is an unnecessary empty line after the class declaration (line 2). According to the checklist, we should not add redundant empty lines after class declaration. 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's a missing space between the class name |
||||||||
|
||||||||
@Override | ||||||||
public void doWork() { | ||||||||
System.out.println("the truck started it`s 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 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 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. Replace the backtick ( |
||||||||
} | ||||||||
|
||||||||
@Override | ||||||||
public void stopWork() { | ||||||||
System.out.println("the truck stopped it`s 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. Similarly, the stop message should be informative. Consider changing it to "Truck stopped 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. Similar to 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. Replace the backtick ( |
||||||||
} | ||||||||
} |
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.