gpt4 book ai didi

android - 程序流程 AppInventor

转载 作者:太空狗 更新时间:2023-10-29 13:27:31 26 4
gpt4 key购买 nike

好吧...没人笑...我正在 MIT/Google Appinventor 中开发一款应用程序。这是一个纲要:

  • 扫描条形码,然后运行图片中的功能。
  • 如果该项目在列表中,则 在库存列表中找到该项目的位置索引。 使用该项目索引,将数量列表中的值递增 1。

  • 如果该项目不在列表中,则 将该项目添加到库存中,并在数量中添加“1”。

我不明白为什么它不起作用,所以我只是在检查我的逻辑中是否存在任何明显的缺陷。如果逻辑看起来很可靠,那么我应该能够找出 Appinventor 问题来让它工作。

enter image description here

最佳答案

这是您的函数(准确地?)翻译成伪代码以帮助我自己(希望其他人)理解:

function addItem:
if inventoryList.contains(scannerResult):
inventoryPosition = inventoryList.positionOf(scannerResult)
quantityPosition = quantityList.positionOf(scannerResult)
quantityItem = quantityList.selectListItemAt(quantityPosition)
quantityList.insert(quantityItem at inventoryPosition)
else
inventoryList.add(scannerResult)
quantityList.add(1)

当扫描结果已经在列表中时,问题似乎出在逻辑上。我不知道相关的 app-inventor 函数,但我认为您想要的更像是:

  if inventoryList.contains(scannerResult):
inventoryPosition = inventoryList.positionOf(scannerResult)
quantity = quantityList.selectListItemAt(inventoryPosition)
quantityList.setListItemAt(quantityPosition to quantity + 1)

最后一行是我不知道如何翻译成 app-inventor 语言的部分,但希望它足以为您指明正确的方向。

关于android - 程序流程 AppInventor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19991923/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com