Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

don-bigdad
Copy link

…s of abstract classes

@@ -1,5 +1,14 @@
package core.basesyntax;

public class MainApp {

public static void main(String[] args) {
Excavator excavator = new Excavator();

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();

Copy link
Contributor

@liliia-ponomarenko liliia-ponomarenko left a 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 {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Machine bulldozer = new Bulldozer();
Machine truck = new Truck();
Machine[] machines = {excavator, truck, bulldozer};
for (Machine machine:machines) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (Machine machine:machines) {
for (Machine machine : machines) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants