2010-02-28 70 views
-4

我工作的一個項目,並具有以下僞代碼:幫助創建一個私有方法

// create a private method, getIntValDialog, that returns an integer value and accepts 
// two string values as arguments 
    // declare and initialize a string variable, sValue, to an empty string 
    // Accept input to sValue from a Input Dialog using smessage, stitle, and a question icon as arguments 
    // return the integer converted value of sValue 
     // end getIntValDialog method 

我有一個想法,但我不太明白如何正確設置它。僞代碼告訴我我必須做什麼,但我只需要一些幫助理解和可視化這是如何工作的。任何幫助,將不勝感激:)

+3

我想標記這是家庭作業 - 它肯定有這種感覺。來自一位從來沒有寫過代碼謀生的教授的壞僞代碼,以及無法遵循它的學生。 – duffymo 2010-02-28 03:38:23

+0

你想知道什麼?您應該編寫一個方法,要求用戶輸入,然後將該輸入作爲整數返回。該方法需要2個參數:輸入對話框的標題和消息。愚蠢的僞代碼 – 2010-02-28 03:39:02

+0

家庭作業問題,零背景工作或嘗試提供。對不起,但這是一個-1。 – Urda 2010-02-28 03:43:37

回答

3

這是我離開你的僞代碼:

// create a private method, getIntValDialog, that returns an integer value and accepts 
// two string values as arguments 
private int getIntValDialog(String smessage, String stitle) 
{ 
    // declare and initialize a string variable, sValue, to an empty string 
    String sValue = ""; 

    // Accept input to sValue from a Input Dialog using smessage, stitle, 
    // and a question icon as arguments 
    // TODO (this is your part of the task) 

    // return the integer converted value of sValue 
    return Integer.valueOf(sValue); 

// end getIntValDialog method 
} 

你把它從這裏開始。

我有一個想法,但我不太 瞭解如何正確設置此 。

一些建議以供將來的問題:如果你真的這樣做有一個想法,請最好的,你可以張貼出來,讓人們糾正錯誤。它會顯示你正在努力的誠意努力。

+0

訪問修飾符應該可能是'私人' – akf 2010-02-28 03:51:05

+0

我明白...謝謝你,但是,這幫助我更好地理解它。 – Holly 2010-02-28 04:13:35

+0

是的,太快了,習慣接管了。我會糾正它。 – duffymo 2010-02-28 11:49:52