返回一个带有更新数据的对象,该对象被传递给公共静态函数
如何返回带有更新数据的对象,并将其传递给公共静态函数?
GetDate.dayName(MyDate.setDate(1984,3))
//MyDate with new info (year, month) will be pass into GetDate.dayName
package hwang.time
{
public class MyDate
{
public static var getYear:Number;
public static var getMonth:Number;
public static function setDate(year:Number, month:Number = 1):Object
{
getYear = year;
getMonth = month
verify()
return null
}
private static function verify():void
{
//something
}
}
}
How can I return an object with an update data, that is pass in to a public static function?
GetDate.dayName(MyDate.setDate(1984,3))
//MyDate with new info (year, month) will be pass into GetDate.dayName
package hwang.time
{
public class MyDate
{
public static var getYear:Number;
public static var getMonth:Number;
public static function setDate(year:Number, month:Number = 1):Object
{
getYear = year;
getMonth = month
verify()
return null
}
private static function verify():void
{
//something
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嗯……不知道有什么困难。您是否尝试过从
verify
简单地访问getYear
?除非我遗漏了什么,否则应该可以:Hmm... not sure what's the difficulty. Have you tried simply accessing
getYear
fromverify
? Unless I'm missing something, that should just work:摆脱静态函数并创建一个“正常”
Date
对象new MyDate(1984,3);
然后在构造函数中验证日期:而不是使用另一个返回日期名称的静态函数,向
MyDate
类添加一个公共函数:整个片段
get rid of the static functions and create a "normal"
Date
objectnew MyDate(1984,3);
and then verify the date iside the constructor:and instead of having another static function returning you the name of the day, add a public function to the
MyDate
class:whole snippet
这就是我的想法。无论如何,感谢您的帮助:)
Here's what I come up with.Thanks for helping anyway :)