日期:2014-05-20 浏览次数:20682 次
public class WhenLie {
public static void main(String[] args) {
Day day;
VillageA a;
VillageB b;
//对每一天进行判断,看前天是否都为说谎日
for (int i = 1; i <= 7; i++) {
day = new Day(i);
a = new VillageA(day);
b = new VillageB(day);
Day beforeYestoday = day.yestaday().yestaday();
boolean a_answer = a.answer(beforeYestoday);
boolean b_answer = b.answer(beforeYestoday);
if (!a_answer && !b_answer) {
System.out.println(i);
}
}
}
}
//A村构建一个类
class VillageA {
boolean isTellLie = true; //true代表说真话
//初始化判定当天是否说谎日
VillageA(Day day) {
if (day.id == 1 || day.id == 3 || day.id == 5) {
isTellLie = false;
}