Skip to content

Commit

Permalink
created 4 classes w/ methods and made loop in main class w/ sout of s…
Browse files Browse the repository at this point in the history
…tart and end work every machine
  • Loading branch information
tsuki99 committed Jul 23, 2023
1 parent ea616af commit da88cff
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/core/basesyntax/Bulldozer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package core.basesyntax;

public class Bulldozer extends Machine{

@Override
public void doWork(){
System.out.println("Bulldozer: start of work");
}

@Override
public void stopWork(){
System.out.println("Bulldozer: stop of work");
}

}
15 changes: 15 additions & 0 deletions src/main/java/core/basesyntax/Excavator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package core.basesyntax;

public class Excavator extends Machine{

@Override
public void doWork(){
System.out.println("Excavator: start of work");
}

@Override
public void stopWork(){
System.out.println("Excavator: stop of work");
}

}
9 changes: 9 additions & 0 deletions src/main/java/core/basesyntax/Machine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package core.basesyntax;

public abstract class Machine {

public abstract void doWork();

public abstract void stopWork();

}
19 changes: 19 additions & 0 deletions src/main/java/core/basesyntax/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,23 @@

public class MainApp {

public static void main(String[] args) {

Truck truck = new Truck();
Bulldozer bulldozer = new Bulldozer();
Excavator excavator = new Excavator();

Machine[] array = {truck, bulldozer, excavator};

for(int i = 0; i < array.length; i++) {

array[i].doWork();
array[i].stopWork();
System.out.println("----------------");
}


}


}
15 changes: 15 additions & 0 deletions src/main/java/core/basesyntax/Truck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package core.basesyntax;

public class Truck extends Machine{

@Override
public void doWork(){
System.out.println("Truck: start of work");
}

@Override
public void stopWork(){
System.out.println("Truck: stop of work");
}

}

0 comments on commit da88cff

Please sign in to comment.