2010-02-28 69 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