-
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 a Machine class that contains doWork and stopWork methods. #2166
base: master
Are you sure you want to change the base?
Conversation
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.
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.
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!"; |
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.
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!"; |
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.
Similarly, the message for stopping work should indicate that it is a Bulldozer that has stopped working.
String[] matrixMachine = {truck.goWork(),bulldozer.goWork(),excavator.goWork(), | ||
truck.stopWork(), bulldozer.stopWork(), excavator.stopWork()}; |
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.
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) { |
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.
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) { |
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.
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.
public String goWork() { | ||
return "Truck started its work!"; | ||
} |
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.
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!
.
public String stopWork() { | ||
return "Truck stopped its work!"; | ||
} |
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.
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!
.
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.