ããªãã¡ã¯ã¿ãªã³ã°ãã®å®å ¨èªç ´ããã®8ã7ç« å¾å
ååã«å¼ãç¶ãã7ç« ã®å¾åã
8æã«èªã¿çµããäºå®ãããã10æãä¸æ¬ã«ã
å§è²ã®é è½(P157)
ã«ãã»ã«åã¯ãå¯ä¸ã®ã¨ã¯è¨ããªãã¾ã§ãããªãã¸ã§ã¯ãæåæè¡ã®éµã§ããã
class Client... //before _manager = john.getDepartment().getManager(); //after _manager = john.getManager(); } class Person{ Department _department; public void setDepartment(Department arg){ _department = arg; } //before public Department getDepartment(){ return _department; } //after å§è²ã¡ã½ãããä½ããgetDepartment()ã¯åé¤ããã public Person getManager() { return _department.getManager(); } } class Department{ //ãã®ã¯ã©ã¹ã¯ãªãã¡ã¯ã¿ãªã³ã°åå¾ã§å¤æ´ãªãã private Person _manager; public Department(Person manager){ _manager = manager; } public Person getManager(){ return _manager; } }
仲ä»äººã®é¤å»(P160)
å§è²ã®é è½ã®éã
é è½ãã©ã®ç¨åº¦æ½ãã®ãè¦æ¥µããã®ã¯å°é£ã§ãã·ã¹ãã ãå¤åããã°ãã®åºæºãå¤åãã¦ããã
é©å½ã ã£ãã«ãã»ã«åããã°ããããã¨æ±ãã«ãããªãããããã¯æªããã¨ã§ã¯ãªããã²ãããç´ããã¨ã
å¤é¨ã¡ã½ããã®å°å ¥(P162)
ãå©ç¨ä¸ã®ãµã¼ãã¯ã©ã¹ã«ã¡ã½ããã追å ããå¿ è¦ããããããã®ã¯ã©ã¹ãå¤æ´ã§ããªããå ´åã«è¡ãã
ç´æã¯äºã¤ã
ä½æããã¡ã½ããã®ç¬¬ä¸å¼æ°ã¯ããµã¼ãã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã¨ããã
決ã¾ã£ãã³ã¡ã³ããã¤ãããï¼//å¤é¨ã¡ã½ããï¼<ãµã¼ãå>ã¯ã©ã¹ã«ããã¹ãï¼
ã³ã¼ãã®ä¾ãå¤ããã¦Eclipseãå
¨åã§åãæ¶ãç·ãã¤ãã¦ããããã ãã©ãããã¯Dateã¯ã©ã¹ã»ã©ããä¾ãä»ã«æµ®ãã°ãªãã®ã§ãã®ã¾ã¾åçµãã¦ã¿ãã
å½æã®Dateã¯ã©ã¹ã¯ãã©ãã®ã·ã¹ãã ã§ãèªç¤¾ãã¬ã¼ã ã¯ã¼ã¯ã¨ãã¦æ¡å¼µãã¦ãããããªãããªã
Date newStart = new Date(previousEnd.getYear(), previousEnd.getMonth(), previousEnd.getDate() + 1); â Date newStart = nextDay(previousEnd); private static Date nextDay(Date arg) { //å¤é¨ã¡ã½ããï¼Dateã¯ã©ã¹ã«ããã¹ã return new Date(arg.getYear(), arg.getMonth(), arg.getDate() + 1); }
å±æçæ¡å¼µã®å°å ¥(P164)
å¤é¨ã¡ã½ããã®å°å
¥ã¯å¯¾è±¡ã¡ã½ããã2ã¤ã¾ã§ããã¡ãã¯3ã¤ä»¥ä¸ã®ã¨ãã«è¡ãã
ãµãã¯ã©ã¹ãã©ããã¼ããã©ã¡ãã§ãæ¡ç¨ã§ãããããã¡ã¦ã©ã¼ã¯å¯è½ãªãã°ä½æ¥ã®å°ãªããµãã¯ã©ã¹åãå§ãã¦ããã
æ°ã¯ã©ã¹ã«ã¯å
ã®ãªãã¸ã§ã¯ããå¼æ°ã¨ããå¤æç¨ã³ã³ã¹ãã©ã¯ã¿ãä½ãããµãã¯ã©ã¹ã«ãããªãsuperã§ãã©ããã¼ãªãå§è²ãã£ã¼ã«ããè¨å®ããã
以ä¸ã¯ãµãã¯ã©ã¹ã®å ´åã®æé ã§ãã©ããã¼ã®å ´åã«ã¤ãã¦ã¯å²æããã
Date newStart = new Date(previousEnd.getYear(), previousEnd.getMonth(), previousEnd.getDate() + 1); â Date newStart = new MfDate(previousEnd).nextDay(); public class MfDate extends Date{ public MfDate(String dateString) { super(dateString); } public MfDate(Date arg) { super(arg.getTime()); } Date nextDay() { return new Date(getYear(), getMonth(), getDate() + 1); } }
次åã¯8ç« ã ãã©ãå
ã¯é·ãã