Skip to content

Commit

Permalink
전략 패턴
Browse files Browse the repository at this point in the history
  • Loading branch information
ZANGZANGS committed Dec 6, 2021
1 parent f3e9416 commit 147eebd
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/gof/dp/strategy/LeastJob.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package gof.dp.strategy;

public class LeastJob implements Scheduler{
@Override
public void getNextCall() {
System.out.println("가장 짧은 작업을 호출한다.");
}

@Override
public void sendCallAgent() {
System.out.println("현재 상담업무가 없거나 상담대기가 가장 작은 상담원에게 콜한다.");
}
}
13 changes: 13 additions & 0 deletions src/gof/dp/strategy/Priority.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package gof.dp.strategy;

public class Priority implements Scheduler{
@Override
public void getNextCall() {
System.out.println("가장 우선순위가 높은 작업을 호출한다.");
}

@Override
public void sendCallAgent() {
System.out.println("현상담 우선순위가 높은 상담원에게 콜한다.");
}
}
13 changes: 13 additions & 0 deletions src/gof/dp/strategy/Roundrobin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package gof.dp.strategy;

public class Roundrobin implements Scheduler{
@Override
public void getNextCall() {
System.out.println("순서대로 작업을 호출한다.");
}

@Override
public void sendCallAgent() {
System.out.println("상담원들에게 순차적으로 돌아가며 콜한다.");
}
}
6 changes: 6 additions & 0 deletions src/gof/dp/strategy/Scheduler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package gof.dp.strategy;

public interface Scheduler {
public void getNextCall();
public void sendCallAgent();
}
34 changes: 34 additions & 0 deletions src/gof/dp/strategy/SchedulerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package gof.dp.strategy;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class SchedulerTest {
public static void main(String[] args) throws IOException {

Scheduler scheduler = null;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

System.out.println("L: 가장 짧은 작업 처리");
System.out.println("P: 가장 우선순위가 높은 작업 우선 처리");
System.out.println("R: 순차적으로 작업 처리");

String input = br.readLine();

if(input.equals("L") || input.equals("ㅣ") ){
scheduler = new LeastJob();
}else if(input.equals("P") || input.equals("p") ){
scheduler = new Priority();
}else if(input.equals("R") || input.equals("r") ){
scheduler = new Roundrobin();
}else{
System.out.println("잘못된 입력입니다.");
return;
}

scheduler.getNextCall();
scheduler.sendCallAgent();

}
}

0 comments on commit 147eebd

Please sign in to comment.