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 a Machine class that contains doWork and stopWork methods. #2166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Yura9827
Copy link

@Yura9827 Yura9827 commented Oct 2, 2024

Created classes Truck, Bulldozer, Excavator that follow methods from Machine. doWork prints that a certain machine has started its work. stopWork prints that certain machines have stopped working. In the MainApp class, a Machine array was created with the Truck, Bulldozer, Excavator methods that output messages from doWork and stopWork.

Created classes Truck, Bulldozer, Excavator that follow methods from Machine.
doWork prints that a certain machine has started its work.
stopWork prints that certain machines have stopped working.
In the MainApp class, a Machine array was created with the Truck, Bulldozer, Excavator methods that output messages from doWork and stopWork.
Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on implementing the Excavator class methods according to the guidelines! 🎉 For the Bulldozer class, just a minor note for future reference: try to make the messages more informative by specifying the machine type. Keep up the good work, and continue refining those details! 👍

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨


@Override
public String goWork() {
return "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 returned here should be more informative and indicate that it is a Bulldozer that is working. Consider including the type of machine in the message.


@Override
public String stopWork() {
return "Bulldozer stopped its work!";

Choose a reason for hiding this comment

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

Similarly, the message for stopping work should indicate that it is a Bulldozer that has stopped working.

Comment on lines +10 to +11
String[] matrixMachine = {truck.goWork(),bulldozer.goWork(),excavator.goWork(),
truck.stopWork(), bulldozer.stopWork(), excavator.stopWork()};

Choose a reason for hiding this comment

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

Using a String array to store the messages from goWork() and stopWork() methods is not necessary. It would be more efficient to call these methods directly inside the loop without storing the return values. This would also make the code more readable and maintainable.

String[] matrixMachine = {truck.goWork(),bulldozer.goWork(),excavator.goWork(),
truck.stopWork(), bulldozer.stopWork(), excavator.stopWork()};

for (String matrix : matrixMachine) {

Choose a reason for hiding this comment

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

The variable name matrixMachine is not informative. It's better to use a name that reflects the data it holds, such as machineStates or machineActions.

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

public class MainApp {
public static void main(String[] args) {

Choose a reason for hiding this comment

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

According to the checklist, we should use abstract references instead of specific ones where possible. Instead of Machine truck = new Truck();, consider using Truck truck = new Truck(); since we are not utilizing polymorphism here.

Comment on lines +6 to +8
public String goWork() {
return "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 returned by the goWork method should be more informative and indicate that it is specifically a Truck that is working. Consider including the type of machine in the message, for example: Truck is starting its work!.

Comment on lines +11 to +13
public String stopWork() {
return "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 goWork method, the message returned by the stopWork method should be more informative. Include the type of machine in the message to indicate it's a Truck, for example: Truck has stopped its work!.

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.

2 participants