【发布时间】:2021-05-12 13:48:45
【问题描述】:
对于我的项目,我必须修改这个方法:
/**
* Determines if this position equals the specified position
*
* @return true of this position and the specified position have the same row
* and column value
*/
@Override
public boolean equals(Object pos) {
return false;
}
我将如何解决这个问题?我知道要修改代码,但我在理解如何处理 'pos' 作为对象时遇到了问题。
在 Position 类中,有两个方法称为“getRow”和“getCol”。我怎么能这样做?
【问题讨论】:
-
您可能必须将
pos类型转换为您的类的任何类型(大概是Position,然后再调用getRow和getCol。