요구 사항

Untitled

모니터링 코드 만들기

public class GumballMachine {
		// 기타 인스턴스 변수
    String location;

    public GumballMachine(String location, int count) {
		    // 기타 생성자 코드
        this.location = location;
    }

    public String getLocation() {
        return location;
    }
		
		// 기타 메소드
}
public class GumballMonitor {
    GumballMachine machine;

    public GumballMonitor(GumballMachine machine) {
        this.machine = machine;
    }

    public void report() {
        System.out.println("Gumball Machine: " + machine.getLocation());
        System.out.println("Current inventory: " + machine.getCount() + " gumballs");
        System.out.println("Current state: " + machine.getState());
    }
}

모니터링 기능 테스트

public class GumballMachineTestDrive {

    public static void main(String[] args) {
        int count = 0;

        if (args.length < 2) {
            System.out.println("GumballMachine <name> <inventory>");
            System.exit(1);
        }

        count = Integer.parseInt(args[1]);
        GumballMachine gumballMachine = new GumballMachine(args[0], count);

				// 기타 코드

        monitor.report();
    }
}

추가적으로 CEO가 뽑기 기계를 원격으로 모니터링 하고 싶어한다.

원격 프록시를 이용해 해결해보자!