帮助伪代码和循环

发布于 2024-10-02 12:28:13 字数 679 浏览 0 评论 0原文

伪代码

Inventory service class

public class Inventory

    // declarations

    private itemnumber : integer
    private originalprice : integer

    public Inventory ()
        itemnumber = 0
        originalprice = 0
        return

public Inventory (ite : integer, ori : integer)
    itemnumber = ite
    originalprice = ori  
    return

public integer getitemnumber( ) 
    return itemnumber


public integer getoriginalprice( ) 
    return originalprice

public void setItemnumber(integer ite) 
    itemnumber = ite
    return


public void setOriginalprice (integer ori) 
    originalprice = ori
    return

End Class

Public class PayReport

PSEUDOCODE

Inventory service class

public class Inventory

    // declarations

    private itemnumber : integer
    private originalprice : integer

    public Inventory ()
        itemnumber = 0
        originalprice = 0
        return

public Inventory (ite : integer, ori : integer)
    itemnumber = ite
    originalprice = ori  
    return

public integer getitemnumber( ) 
    return itemnumber


public integer getoriginalprice( ) 
    return originalprice

public void setItemnumber(integer ite) 
    itemnumber = ite
    return


public void setOriginalprice (integer ori) 
    originalprice = ori
    return

End Class

Public class PayReport

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迟月 2024-10-09 12:28:13

在我看来,第四部分有点误导。我认为目的是读取包含库存项目的文件,其中每个项目都位于单独的行上。因此,您将有一种方法可以读取文件,并在该方法中迭代文件中的每一行并添加库存项目。也许这是错误的,但似乎最有可能......或者这不是#1 的问题?

至于循环,我不明白你到底在问什么。您可以硬编码 7(7 天),或者有一个单独的成员,例如 numDaysOfSale,然后循环遍历并在该循环中进行百分比计算。

希望能有点帮助...
- 戴夫

Seems to me that the iv part is kind of misleading. I think the intent was to read a file that contains inventory item[s] where each item is on a separate line. So you would have one method that would read the file and in that method iterate over each line in the file and add an inventory item. Maybe that is wrong but seems the most likely... Or is that not the question for #1?

As for the looping, I'm not understanding exactly what you are asking. You could just hard-code 7 (for the 7 days) or have a separate member something like numDaysOfSale then just loop over that and do the percentage calculation in that loop.

Hope that helps a little...
- Dave

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文