-
Notifications
You must be signed in to change notification settings - Fork 1.8k
create new class and method to output #2414
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
base: master
Are you sure you want to change the base?
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.
Review Summary
I’m requesting changes because critical requirements are missing or incorrect, which will block compilation and/or tests.
Critical issues to fix
- Missing required files/classes (blocker): The project must include all of the following together for verification and compilation:
Machine
(abstract),Truck
,Bulldozer
,Excavator
(extendMachine
), andMainApp
that creates aMachine[]
of these and iterates callingdoWork()
/stopWork()
. Based on the submitted files, at least one of these is missing or incomplete in multiple places (e.g., MainApp referencesTruck
/Excavator
that aren’t present). Please add them as specified. - Message wording mismatch (tests likely to fail): In
Truck.java
andBulldozer.java
andExcavator.java
, thedoWork()
message must exactly include the machine type and the required action wording: use " started working" (e.g., "Truck started working", "Bulldozer started working", "Excavator started working"). Current variants like "started its work" may cause string-based tests to fail.
Where and how to fix (examples)
- src/main/java/core/basesyntax/Machine.java: Ensure both methods exist without extra blank lines:
public abstract void doWork();
andpublic abstract void stopWork();
on adjacent lines. - src/main/java/core/basesyntax/Truck.java: Update
doWork()
to print "Truck started working". Remove redundant blank lines after package/class and between methods. Add@Override
above both methods. - src/main/java/core/basesyntax/Bulldozer.java: Update
doWork()
to print "Bulldozer started working". Remove the blank line after class declaration and between methods. Add@Override
annotations. - src/main/java/core/basesyntax/Excavator.java: Update
doWork()
to print "Excavator started working". Remove redundant blank lines. Add@Override
annotations. - src/main/java/core/basesyntax/MainApp.java: Ensure it creates
Machine[] machines = { new Truck(), new Bulldozer(), new Excavator() };
and iterates callingdoWork()
thenstopWork()
on each element, using abstract references.
Minor (non-blocking but required by style checklist)
- Remove redundant empty lines after class declarations and between method signatures/bodies in all affected files.
You’ve got the right structure and intent; once you add the missing files and standardize the messages, the solution should compile and meet the checklist. Keep going—you’re close!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review
button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor
tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
@@ -0,0 +1,12 @@ | |||
package core.basesyntax; |
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.
Missing required project elements: the abstract Machine class, and the other concrete classes (Truck and Excavator), plus the MainApp entry point are not present in the submitted files. This violates checklist item 1.1: "Create an abstract class named Machine that declares two abstract methods: - public abstract void doWork(); - public abstract void stopWork();" and checklist item 1.2: "Create three concrete classes: Truck, Bulldozer, and Excavator that inherit from Machine." It also violates checklist item 1.5: "Create a MainApp class with a main method that: - Creates an array (or collection) of Machine references containing instances of Truck, Bulldozer, and Excavator. - Iterates over the array and calls doWork() and stopWork() for each element." Additionally, checklist item 3.2 states: "In MainApp, create instances with abstract references, e.g., Machine m = new Truck(); and store them in a Machine[] (or similar). Avoid using concrete-type references like Truck t = new Truck(); when not necessary." Please add these missing files so I can fully verify the task requirements and polymorphism behavior.
public class Bulldozer extends Machine { | ||
|
||
public void doWork() { | ||
System.out.println("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.
doWork() message wording doesn't exactly match the checklist requirement. This violates checklist item 3.1: "Messages printed by doWork() and stopWork() must clearly include the machine type name (Truck, Bulldozer, or Excavator) and the action (started/stopped working)." Current text: "Bulldozer started its work"
. Change it to explicitly state the required action wording, e.g. "Bulldozer started working"
, to match the specification.
package core.basesyntax; | ||
|
||
public class Bulldozer extends Machine { | ||
|
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.
Redundant empty line immediately after the class declaration. Please remove it to follow the style requirement: "Do not add redundant empty lines after class declarations or method signatures." (checklist item 4.1).
public void doWork() { | ||
System.out.println("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.
Redundant empty line between methods. Please remove it to follow the style requirement: "Do not add redundant empty lines after class declarations or method signatures." (checklist item 4.1).
|
||
public class Bulldozer extends Machine { | ||
|
||
public void doWork() { |
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.
Suggestion: add the @OverRide annotation above doWork(). While not strictly required by the checklist, it makes the overriding intent explicit and enables compiler checks. Example:
@Override
public void doWork() { ... }
@@ -0,0 +1,12 @@ | |||
package core.basesyntax; | |||
|
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.
Redundant empty line immediately after the package declaration. Please remove it to follow the style requirement: "Do not add redundant empty lines after class declarations or method signatures." (checklist item 4.1).
package core.basesyntax; | ||
|
||
public class Truck extends Machine { | ||
|
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.
Redundant empty line immediately after the class declaration. Please remove it to follow the style requirement: "Do not add redundant empty lines after class declarations or method signatures." (checklist item 4.1).
public void doWork() { | ||
System.out.println("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.
Redundant empty line between methods. Please remove it to follow the style requirement: "Do not add redundant empty lines after class declarations or method signatures." (checklist item 4.1).
|
||
public class Truck extends Machine { | ||
|
||
public void doWork() { |
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.
Suggestion: add the @Override
annotation above doWork()
to make the overriding explicit and enable compiler checks. Example:
@Override
public void doWork() { ... }
System.out.println("Truck started its work"); | ||
} | ||
|
||
public 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.
Suggestion: add the @Override
annotation above stopWork()
as well. This is recommended for clarity and compile-time verification.
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.
Review Summary
Decision: REQUEST_CHANGES
Your implementation meets the functional requirements (abstract Machine
, concrete Truck
/Bulldozer
/Excavator
, and MainApp
demonstrating polymorphism). However, there are explicit checklist violations regarding redundant empty lines that must be fixed to pass style checks.
Critical issues to fix (checklist violations):
- src/main/java/core/basesyntax/Bulldozer.java
- Remove the blank line immediately after the
package
declaration (line 2). - Remove the redundant blank line between the two method blocks.
- Remove the blank line immediately after the
- src/main/java/core/basesyntax/Excavator.java
- Remove the empty line at line 8 (between the end of
doWork()
and the@Override
forstopWork()
). Also avoid blank lines immediately after method signatures.
- Remove the empty line at line 8 (between the end of
- src/main/java/core/basesyntax/Machine.java
- Remove the blank line between
public abstract void doWork();
andpublic abstract void stopWork();
so they are adjacent.
- Remove the blank line between
- src/main/java/core/basesyntax/Truck.java
- Remove the blank line at line 2 (between the
package
declaration and the class declaration). - Remove the blank line at line 8 (between the end of
doWork()
and the@Override
forstopWork()
).
- Remove the blank line at line 2 (between the
Why this matters: the project checklist states “Please don’t add redundant empty lines to your code,” and style checks may fail if these remain. After removing these lines, your code should fully comply. Functionally, everything looks good—nice job on clear messages and correct use of polymorphism. Keep it up!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review
button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor
tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
@@ -0,0 +1,13 @@ | |||
package core.basesyntax; | |||
|
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.
This file has a redundant blank line immediately after the package declaration. Please remove it to comply with the checklist item: "Please don't add redundant empty lines to your code."
public void doWork() { | ||
System.out.println("Bulldozer started 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.
This blank line between the two method blocks is redundant. Remove it to comply with the checklist item: "Please don't add redundant empty lines to your code."
public void doWork() { | ||
System.out.println("Excavator started 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.
This violates the checklist item: "Please don't add redundant empty lines to your code." Remove the blank line at line 8 — the empty line between the end of doWork()
and the @Override
for stopWork()
is redundant. Also keep in mind the related guideline: "Do not include redundant empty lines immediately after class declarations or method signatures."
|
||
public abstract class Machine { | ||
public abstract void doWork(); | ||
|
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.
This file violates the checklist item "Please don't add redundant empty lines to your code." There is a redundant empty line between the two abstract method declarations. Remove the blank line so public abstract void doWork();
and public abstract void stopWork();
are on adjacent lines.
@@ -0,0 +1,13 @@ | |||
package core.basesyntax; | |||
|
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.
This violates the checklist item: "Please don't add redundant empty lines to your code." Remove the redundant empty line at line 2 (blank line between the package declaration and the class declaration).
public void doWork() { | ||
System.out.println("Truck started 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.
This violates the checklist item: "Please don't add redundant empty lines to your code." Remove the redundant empty line at line 8 (blank line between the end of doWork()
and the @Override
for 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.
Review Summary
Educational approval: Functionality looks solid — you created a proper public abstract Machine with public abstract void doWork();
and public abstract void stopWork();
, and your Truck, Bulldozer, and Excavator correctly extend Machine and print clear English start/stop messages. MainApp demonstrates polymorphism via a Machine[]
and iterates to call both methods — great job following the core OOP requirement.
Critical issues to fix (style/CI blockers):
- Checkstyle errors (EmptyLineSeparator, NewlineAtEndOfFile) across 5 files prevent the Maven build from passing. These come from missing or extra blank lines and missing EOF newlines.
- How to fix quickly:
- Ensure each file ends with exactly one newline (EOF).
- Add a blank line after the
package
/imports and beforepublic class ...
where missing (e.g., Bulldozer.java line 2, Truck.java line 2). - Ensure method blocks are properly separated without extra blank lines; remove blank lines flagged between methods (e.g., Excavator.java around the line between
doWork()
andstopWork()
; Truck.java and Bulldozer.java similarly). - In Machine.java, place the two abstract method declarations adjacent without an extra blank line if your Checkstyle requires it.
Minor improvement: keep messages consistently informative (you already do this) and rely on IDE auto-format or run mvn verify
locally to catch style issues early. Overall, strong OOP implementation — just tidy the whitespace to make CI green. Keep it up!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.