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

First solution #2277

Closed
wants to merge 2 commits into from
Closed

First solution #2277

wants to merge 2 commits into from

Conversation

dariuszb
Copy link

@dariuszb dariuszb commented Feb 4, 2025

No description provided.

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.

Thank you for your submission! 🚀 While your code has been approved to help you progress in your learning journey, there are several important issues that need your attention:

  1. Class Declaration: The classes Truck, Bulldozer, and Excavator are incorrectly declared as abstract. These should be concrete classes to allow instantiation in the MainApp class.

  2. Method Implementation: In the Excavator class, the stopWork() method prints "The truck is not working" instead of "The excavator is not working". Please correct this inconsistency.

  3. Array Initialization: The syntax for initializing the machines array is incorrect. Use curly braces for array initialization: machines = new Machine[]{truck, bulldozer, excavator};.

  4. Abstract Method Declaration: The stopWork method in the Machine class should not have an empty block {}. It should be declared as public abstract void stopWork();.

  5. Typographical Error: There is a typo in the Bulldozer class output message: 'buldozer' should be corrected to 'bulldozer'.

  6. Access Modifiers: Ensure that appropriate access modifiers are used to adhere to encapsulation principles.

Please address these issues to improve your code quality and functionality. Keep up the good work and continue learning from these experiences! 😊

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


@Override
public void doWork() {
System.out.println("The buldozer is working");

Choose a reason for hiding this comment

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

There is a typo in the message: 'buldozer' should be 'bulldozer'.

}
@Override
public void stopWork() {
System.out.println("The truck is not working");

Choose a reason for hiding this comment

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

The message in stopWork method is inconsistent: 'The truck is not working' should be 'The excavator is not working' to match the class name.


public abstract void doWork();

public abstract void stopWork(); {}

Choose a reason for hiding this comment

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

The stopWork method should not have an empty block {}. It should be declared as public abstract void stopWork(); similar to doWork.


}
Machine truck = new Truck() {

Choose a reason for hiding this comment

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

You cannot instantiate an abstract class directly. Consider creating concrete subclasses of Truck, Bulldozer, and Excavator and instantiate those instead.

}
Machine truck = new Truck() {
};
Machine bulldozer = new Bulldozer() {

Choose a reason for hiding this comment

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

You cannot instantiate an abstract class directly. Consider creating concrete subclasses of Truck, Bulldozer, and Excavator and instantiate those instead.

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

You cannot instantiate an abstract class directly. Consider creating concrete subclasses of Truck, Bulldozer, and Excavator and instantiate those instead.



Machine[] machines = new Machine[3];
machines = (truck, bulldozer, excavator)

Choose a reason for hiding this comment

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

The syntax for initializing the machines array is incorrect. Use curly braces for array initialization: machines = new Machine[]{truck, bulldozer, excavator};.

@dariuszb dariuszb closed this Feb 13, 2025
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