鱼C论坛

 找回密码
 立即注册
查看: 597|回复: 3

求助如何在每运行四次清空while

[复制链接]
发表于 2022-11-13 23:52:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
求助如何在每运行四次以后执行一次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();
  }
  
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-11-23 16:52:48 | 显示全部楼层
谢谢,解决疑惑了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-11-23 16:52:56 | 显示全部楼层
蛮好
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-11-24 13:59:17 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-23 21:38

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表