-
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
create abstract class Machine and some machines and override 2 method… #1564
base: master
Are you sure you want to change the base?
Conversation
…s of abstract classes
@@ -1,5 +1,14 @@ | |||
package core.basesyntax; | |||
|
|||
public class MainApp { | |||
|
|||
public static void main(String[] args) { | |||
Excavator excavator = new Excavator(); |
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.
Your implementation won’t allow us to use polymorphism in the code. Your reference is bonded to specific implementation, but it is always better to depend on the abstraction.
Machine excavator = new Excavator();
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.
Good job!
package core.basesyntax; | ||
|
||
public abstract class Machine { | ||
|
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.
Machine bulldozer = new Bulldozer(); | ||
Machine truck = new Truck(); | ||
Machine[] machines = {excavator, truck, bulldozer}; | ||
for (Machine machine:machines) { |
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.
for (Machine machine:machines) { | |
for (Machine machine : machines) { |
…s of abstract classes