我在名为Pokemon的类中具有此功能,我想做的是整体引用当前对象,并将其通过int .use传递。 (我知道您可以使用该对象根据对象引用特定的数据,因此我认为您可以对整个对象进行处理)。非常感谢您的帮助。
public boolean attack(int m,Pokemon p) {
boolean hit = true;
//check what move the use and take away a pp and return it
if (m == 1) {
hit = m1.use(p.getType1(), p.getType2(),**this is where I want to pass the object**);
if (hit == true) {
return true;
} else {
return false;
}
} else if (m == 2) {
hit = m2.use(p.getType1(), p.getType2(),**this is where I want to pass the object**);
if (hit == true) {
return true;
} else {
return false;
}
} else if (m == 3) {
hit = m3.use(p.getType1(), p.getType2(),**this is where I want to pass the object**);
if (hit == true) {
return true;
} else {
return false;
}
} else if (m == 4) {
hit = m4.use(p.getType1(), p.getType2(),**this is where I want to pass the object**);
if (hit == true) {
return true;
} else {
return false;
}
} else {
return true;
}
}