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

created classes, overridden abstract methods, and created an array of… #2119

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main/java/core/basesyntax/Bulldozer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package core.basesyntax;

Choose a reason for hiding this comment

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

Suggested change
package core.basesyntax;
package core.basesyntax;


public class Bulldozer extends Machine{

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The 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");

Choose a reason for hiding this comment

The 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.'

Choose a reason for hiding this comment

The 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 it is a Bulldozer that is working. For example, 'Bulldozer started its work'. Also, use 'its' instead of it's to indicate possession.

}

@Override
public void stopWork() {
System.out.println("the bulldozer stopped it`s work");

Choose a reason for hiding this comment

The 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'.

Choose a reason for hiding this comment

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

Similarly, the message in the stopWork method should be more informative and indicate that it is a Bulldozer that has stopped working. For example, 'Bulldozer stopped its work'. Again, use 'its' instead of it's.

}
}
15 changes: 15 additions & 0 deletions src/main/java/core/basesyntax/Excavator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package core.basesyntax;

Choose a reason for hiding this comment

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

Suggested change
package core.basesyntax;
package core.basesyntax;


public class Excavator extends Machine {

@Override
public void doWork() {
System.out.println("the excavator started it`s work");

Choose a reason for hiding this comment

The 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 it is an Excavator that is working. Consider specifying the machine type in the message.

Choose a reason for hiding this comment

The 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");

Choose a reason for hiding this comment

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

Similarly, the message in the stopWork method should indicate that it is an Excavator that has stopped working. Make sure the message is clear and informative.

Choose a reason for hiding this comment

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

Use proper apostrophes in it's instead of backticks. The correct punctuation for contraction of 'it is' is it's.

Choose a reason for hiding this comment

The 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.'

}
}
6 changes: 6 additions & 0 deletions src/main/java/core/basesyntax/Machine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package core.basesyntax;

Choose a reason for hiding this comment

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

Suggested change
package core.basesyntax;
package core.basesyntax;


public abstract class Machine {
public abstract void doWork();
public abstract void stopWork();
}
12 changes: 11 additions & 1 deletion src/main/java/core/basesyntax/MainApp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package core.basesyntax;

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

The 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};

Choose a reason for hiding this comment

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

The array name machine should be plural to reflect that it contains multiple machines. A better name would be machines. This enhances the readability and understanding of the code.


for (Machine m : machine) {
m.doWork();
m.stopWork();
System.out.println();

Choose a reason for hiding this comment

The 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.

}
}
}
14 changes: 14 additions & 0 deletions src/main/java/core/basesyntax/Truck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package core.basesyntax;

Choose a reason for hiding this comment

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

Suggested change
package core.basesyntax;
package core.basesyntax;


public class Truck extends Machine{

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

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

There's a missing space between the class name Truck and the curly brace {. It should be Truck extends Machine { to follow Java code conventions.


@Override
public void doWork() {
System.out.println("the truck started it`s work");

Choose a reason for hiding this comment

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

The message in the System.out.println should be more informative and indicate the type of machine. For example, "Truck started its work".

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 that it is a Truck that is working. For example: System.out.println("Truck started its work.");

Choose a reason for hiding this comment

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

Replace the backtick () with an apostrophe (') in it'sto use the correct punctuation for the contraction ofit is`.

}

@Override
public void stopWork() {
System.out.println("the truck stopped it`s work");

Choose a reason for hiding this comment

The 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".

Choose a reason for hiding this comment

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

Similar to the doWork method, the message should be more informative. Use Truck stopped its work. to clearly indicate which machine stopped working.

Choose a reason for hiding this comment

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

Replace the backtick () with an apostrophe (') in it'sto use the correct punctuation for the contraction ofit is`.

}
}
Loading