# 一个逻辑问题_张村说谎李村不说谎

public class TestLie {

/**
* @param args
*/
public static void main(String[] args) {
String[] days = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
boolean[] lieArray_zhang = {true, false, true, false, true, false, true};
boolean[] lieArray_li = {false, true, false, true, false, true, true};
Person zhang3 = new Person("zhang3", lieArray_zhang);
Person li4 = new Person("li4   ", lieArray_li);

for (int i = 0; i < 7; i++) {
System.out.println("Today is " + days[i]);
zhang3.say(i);
li4.say(i);
}

}

}

class Person {
String name;
boolean[] lieArray;

public Person(String name, boolean[] lieArray) {
this.name = name;
this.lieArray = lieArray;
}

public void say(int day) {
int f = (day + 5) % 7;
if (lieArray[day]) {
// today is lie day
if (lieArray[f]) {
System.out.println("    " + name
+ " : The day before yesterday I not lay.");
} else {
System.out.println("    " + name
+ " : The day before yesterday I lay.");
}
} else {
// today is not lie day
if (lieArray[f]) {
System.out.println("    " + name
+ " : The day before yesterday I lay.");
} else {
System.out.println("    " + name
+ " : The day before yesterday I not lay.");
}
}
}
}

Today is Monday
zhang3 : The day before yesterday I lay.
li4    : The day before yesterday I lay.
Today is Tuesday
zhang3 : The day before yesterday I lay.
li4    : The day before yesterday I not lay.
Today is Wednesday
zhang3 : The day before yesterday I not lay.
li4    : The day before yesterday I not lay.
Today is Thursday
zhang3 : The day before yesterday I not lay.
li4    : The day before yesterday I not lay.
Today is Friday
zhang3 : The day before yesterday I not lay.
li4    : The day before yesterday I not lay.
Today is Saturday
zhang3 : The day before yesterday I not lay.
li4    : The day before yesterday I not lay.
Today is Sunday
zhang3 : The day before yesterday I not lay.
li4    : The day before yesterday I lay.