
Intellij 내에서 Diagram 확인할 수 있음.
Starter: 시동걸기
Model: 핵심 계산을 하는 두뇌, 선수, 자료
View: 외부와 소통창구(Input, Output)
Controller: 매니저, 지휘자

(GUI 활용)
public class Christmas {
public static void main(String[] args) {
Model m = new Model();
View v = new View();
Controller c = new Controller();
c.showResult(m,v);
}
}
import java.time.LocalDate;
import java.time.Period;
public class Model {
Period getResult(){
LocalDate today = LocalDate.now();
LocalDate christmas = LocalDate.of(today.getYear(), 12, 25);
return Period.between(today,christmas);
}
}
import javax.swing.*;
import java.time.Period;
public class View {
void showResult(Period p){
JOptionPane.showMessageDialog(null, "올해 크리스마스까지 "+p.getMonths()+" 달하고"+p.getDays()+" 일 남았다!");
}
}
public class Controller {
void showResult(Model m, View v){
m.getResult();
v.showResult(m.getResult());
}
}