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 attempt #2207

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# jv-oop

- Create class Machine containing methods `public abstract void doWork()` and `public abstract void stopWork()`.
- Create classes `Truck`, `Bulldozer`, and `Excavator` that will inherit from `Machine`.
- Create class core.basesyntax.Machine containing methods `public abstract void doWork()` and `public abstract void stopWork()`.

Choose a reason for hiding this comment

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

revert changes

Copy link
Contributor

Choose a reason for hiding this comment

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

not fixed

- Create classes `core.basesyntax.Truck`, `core.basesyntax.Bulldozer`, and `core.basesyntax.Excavator` that will inherit from `core.basesyntax.Machine`.
- In those classes override `doWork()`, so it will print a message that a certain machine started its work.
- Override `stopWork()` as well. It should print messages that certain machines stopped working.
- In the `MainApp` class create a `Machine` array with `Truck`, `Bulldozer`, and `Excavator` and call methods `doWork()` and `stopWork()` in a loop.
- In the `MainApp` class create a `core.basesyntax.Machine` array with `core.basesyntax.Truck`, `core.basesyntax.Bulldozer`, and `core.basesyntax.Excavator` and call methods `doWork()` and `stopWork()` in a loop.

#### [Try to avoid these common mistakes, while solving task](./checklist.md)
2 changes: 1 addition & 1 deletion checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Main {

#### Write informative messages in methods.
- Use English only and make messages informative
- The message should indicate what type of `Machine` is working right now `Truck`, `Bulldozer` or `Excavator`.
- The message should indicate what type of `core.basesyntax.Machine` is working right now `core.basesyntax.Truck`, `core.basesyntax.Bulldozer` or `core.basesyntax.Excavator`.

Choose a reason for hiding this comment

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

revert changes

Copy link
Contributor

Choose a reason for hiding this comment

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

not fixed


#### Use abstract references instead of specific ones where possible:
* Bad example:
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/core/basesyntax/Bulldozer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package core.basesyntax;

import core.basesyntax.Machine;

public class Bulldozer extends Machine {
@Override
public void doWork() {
System.out.println("core.basesyntax.Bulldozer has started working.");

Choose a reason for hiding this comment

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

same for all messages

Suggested change
System.out.println("core.basesyntax.Bulldozer has started working.");
System.out.println("Bulldozer has started working.");

Copy link
Contributor

Choose a reason for hiding this comment

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

not fixed (fix it everywhere)

}

@Override
public void stopWork() {
System.out.println("core.basesyntax.Bulldozer has stopped working.");
}
}
16 changes: 16 additions & 0 deletions src/test/java/core/basesyntax/Excavator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package core.basesyntax;

import core.basesyntax.Machine;

public class Excavator extends Machine {
@Override
public void doWork() {
System.out.println("core.basesyntax.Excavator has started working.");
}

@Override
public void stopWork() {
System.out.println("core.basesyntax.Excavator has stopped working.");
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Leave only one empty line

6 changes: 6 additions & 0 deletions src/test/java/core/basesyntax/Machine.java
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();

Choose a reason for hiding this comment

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

check tabulation

Copy link
Author

Choose a reason for hiding this comment

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

corrected

Copy link
Contributor

Choose a reason for hiding this comment

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

not fixed

public abstract void stopWork();
}
12 changes: 12 additions & 0 deletions src/test/java/core/basesyntax/MainAppTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
package core.basesyntax;

public class MainAppTest {
public static void main(String[] args) {
final int MACHINE_COUNT = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static void main(String[] args) {
final int MACHINE_COUNT = 3;
private static final int MACHINE_COUNT = 3;
public static void main(String[] args) {

Make this variable constant

Machine[] machines = new Machine[MACHINE_COUNT];
machines[0] = new Truck();
machines[1] = new Bulldozer();
machines[2] = new Excavator();

Choose a reason for hiding this comment

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

it could be done in 1 line using initialization values

Copy link
Author

Choose a reason for hiding this comment

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

done ! thanks


Choose a reason for hiding this comment

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

remove redundant empty line

Copy link
Author

Choose a reason for hiding this comment

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

I tried . it does not let me remove them in intelllij idea


for (Machine machine : machines) {
machine.doWork();
machine.stopWork();
}
}
}
13 changes: 13 additions & 0 deletions src/test/java/core/basesyntax/Truck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package core.basesyntax;

public class Truck extends Machine {
@Override
public void doWork() {
System.out.println("core.basesyntax.Truck has started working.");
}

@Override
public void stopWork() {
System.out.println("core.basesyntax.Truck has stopped working.");
}
}
Loading