-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
First solution #2277
Conversation
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.
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:
-
Class Declaration: The classes
Truck
,Bulldozer
, andExcavator
are incorrectly declared asabstract
. These should be concrete classes to allow instantiation in theMainApp
class. -
Method Implementation: In the
Excavator
class, thestopWork()
method prints "The truck is not working" instead of "The excavator is not working". Please correct this inconsistency. -
Array Initialization: The syntax for initializing the
machines
array is incorrect. Use curly braces for array initialization:machines = new Machine[]{truck, bulldozer, excavator};
. -
Abstract Method Declaration: The
stopWork
method in theMachine
class should not have an empty block{}
. It should be declared aspublic abstract void stopWork();
. -
Typographical Error: There is a typo in the
Bulldozer
class output message: 'buldozer' should be corrected to 'bulldozer'. -
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"); |
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.
There is a typo in the message: 'buldozer' should be 'bulldozer'.
} | ||
@Override | ||
public void stopWork() { | ||
System.out.println("The truck is not working"); |
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 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(); {} |
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 stopWork
method should not have an empty block {}
. It should be declared as public abstract void stopWork();
similar to doWork
.
|
||
} | ||
Machine truck = new Truck() { |
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.
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() { |
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.
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() { |
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.
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) |
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 syntax for initializing the machines
array is incorrect. Use curly braces for array initialization: machines = new Machine[]{truck, bulldozer, excavator};
.
No description provided.