求助如何在每运行四次清空while
求助如何在每运行四次以后执行一次clear,以让if中能继续运行import java.util.Map;
import java.util.List;
class ConversationBubbles {
List<Map.Entry<String, String>> conversation;
int currentBubble;
ConversationBubbles() {
conversation = new ArrayList<>();
currentBubble = 0;
}
void add(String human, String bot) {
conversation.add(Map.entry(human, bot));
}
void display() {
int i = 0;
pushStyle();
while (i < 4) {
if (i < conversation.size()) {
Map.Entry<String, String> content = conversation.get(i);
float boxWidth = width / 2.5-10;
float boxHeight = height / 8;
fill(#91F7C0);
rect(10, i * (height / 5), boxWidth, boxHeight, 20, 20, 20, 0);
fill(0);
text(content.getKey(), 15, i * (height / 5) + 0.1 * boxHeight , boxWidth, boxHeight);
fill(#91CFF7);
rect(width - width / 2.5 - 10, (i + 0.5) * (height / 5), boxWidth, boxHeight, 20, 20, 0, 20);
fill(0);
text(content.getValue(), width - width / 2.5, (i + 0.5) * (height / 5) + 0.2 * boxHeight, boxWidth, boxHeight);
}
i++;
}
popStyle();
}
} 谢谢,解决疑惑了 蛮好 {:5_108:}
页:
[1]