-
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
Final solution #2107
base: master
Are you sure you want to change the base?
Final solution #2107
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package core.basesyntax; | ||
|
||
public class Bulldozer extends Machine{ | ||
|
||
|
||
@Override | ||
public void doWork() { | ||
System.out.println("Bulldozer start working!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message in 'System.out.println' should be more informative. It should indicate that it is a 'Bulldozer' that is working. Although the message does include 'Bulldozer', consider rephrasing to 'The bulldozer has started working' to be more descriptive. |
||
} | ||
|
||
@Override | ||
public void stopWork() { | ||
System.out.println("Bulldozer stop working!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message in 'System.out.println' should be more informative. It should indicate that it is a 'Bulldozer' that has stopped working. Consider rephrasing to 'The bulldozer has stopped working' to be more descriptive. |
||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package core.basesyntax; | ||
|
||
public class Excavator extends Machine { | ||
|
||
|
||
@Override | ||
public void doWork() { | ||
System.out.println("Excavator start working!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message "Excavator start working!" should be more informative and indicate that it is an Excavator that is working. Consider specifying the action the Excavator is performing, for example, "Excavator is digging." |
||
} | ||
|
||
@Override | ||
public void stopWork() { | ||
System.out.println("Excavator stop working!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, the stop message "Excavator stop working!" should be more informative. It could be improved to "Excavator has finished digging." to clearly indicate the state of the Excavator. |
||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package core.basesyntax; | ||
|
||
public abstract class Machine { | ||
public abstract void doWork(); | ||
public abstract void stopWork(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,32 @@ | ||
package core.basesyntax; | ||
|
||
public class MainApp { | ||
public static void main(String[] args) { | ||
Machine truck; | ||
truck = new Truck(); | ||
|
||
Machine bulldozer = new Bulldozer(); | ||
|
||
Machine excavator = new Excavator(); | ||
//tablica z obiektami | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature. |
||
|
||
Machine[] carPark = {truck , bulldozer , excavator }; | ||
|
||
// stworzyc petle for ktora wyswietli do i stop work | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature. |
||
|
||
for (int i = 0; i < carPark.length; i++) { | ||
carPark[i].doWork(); | ||
carPark[i].stopWork(); | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature. |
||
} | ||
|
||
|
||
// stworzyc maszyny z podanych wczesniej 3 typow | ||
// i sprawdzic czy wywietlaja sie wiadomosci na konsoli | ||
|
||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove these redundant empty lines to improve the readability of your code. |
||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package core.basesyntax; | ||
|
||
public class Truck extends Machine { | ||
|
||
@Override | ||
public void doWork() { | ||
System.out.println("Truck start working!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message 'Truck start working!' should be more informative and indicate that it's a Truck that is working. Consider rephrasing it to include the type of machine, for example: 'Truck is now working.' |
||
|
||
} | ||
|
||
@Override | ||
public void stopWork() { | ||
System.out.println("Truck stop working!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, the message 'Truck stop working!' should clearly indicate the machine type. You could rephrase it to 'Truck has stopped working.' to make it more informative. |
||
|
||
} | ||
} |
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 should be a space between the class name and the curly brace to follow the Java code conventions.