2010-11-10 61 views
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 
+2

這將真正幫助那些試圖幫助,如果你可以改變你的代碼的格式。用反引號(即\'code \')和縮進來包圍它。 :) **編輯:**縮進,不反引號。然後你可以縮進。 – 2010-11-10 21:44:22

+0

@Andrew:但不是兩個!內嵌文本的反引號。 – 2010-11-10 21:46:33

+0

@Roger啊,我的壞。編輯。 – 2010-11-10 21:48:28

回答

0

在我看來,在第四部分是種誤導。我認爲其目的是讀取包含庫存項目的文件,其中每個項目位於不同的行上。因此,您將有一種方法可以讀取文件,並在該方法中迭代文件中的每一行並添加庫存項目。也許這是錯誤的,但似乎是最有可能的......或者這不是#1的問題嗎?

至於循環,我不完全理解你在問什麼。你可以硬編碼7(7天),或者讓一個單獨的成員像numDaysOfSale那樣循環,然後在該循​​環中進行百分比計算。

希望幫助一點點... - 戴夫

+0

對於循環是我正確或不正確,因爲它表示在接下來的7天降低10%的價格。 – james 2010-11-10 22:00:04

+0

是的第四個問題是誤導,我仍然困惑怎麼辦,當我創建一個對象/方法時,我列出的原始項目或什麼,我有該部分的問號。 – james 2010-11-10 22:00:47

+0

好吧,我不知道如何格式化,所以如果其他人可以請做: 好吧,因此對於循環我會說這樣的事情會好一點: '代碼' ... onePrice =(讀取(Inventory.txt))//在這裏你已經「準備讀取」 ,而一個價格不在文件末尾 //打印一張價格 //閱讀下一個價格。 onePrice =(read(Inventory.txt)) endwhile 'code' – Merky 2010-11-10 22:11:05