interface People{
String eat();
}
public class Man implements People {
public boolean isDrinkWine;
public String eat(){
isDrinkWine = true;
return "I can't eat any more; I'm full up.";
}
public String gaming(){
return "I like gaming."
}
}
public class Women implements People {
public boolean isDrinkJuice;
public String eat(){
isDrinkJuice = true;
return "I can't eat any more; I'm full up.";
}
public String dancing(){
return "I like dancing."
}
}
@Test
public void testPeopleEat(){
People people = new Man();
assertEquals("I can't eat any more; I'm full up.", people.eat());
people = new Women();
assertEquals("I can't eat any more; I'm full up.", people.eat());
}
@Test
public void testManGaming(){
Man man = new Man();
assertEquals("I like gaming.", man.gaming());
}
@Test
public void testWomenDancing(){
Women women = new Women();
assertEquals("I like dancing.", women.dancing())
}
例如
代码仅供说明问题