我已经写了一个类来创建和战斗口袋妖怪,但我无法弄清楚如何在测试者类中调用战斗方法来测试我写的类。
我的任务是编写和测试模拟两个口袋妖怪之间的战斗模拟。每个口袋妖怪都有一个健康值,一个强度值和一个速度值。健康值,强度值和速度值作为参数传递给构造函数。这些值最初必须介于1和300之间,最初应该为非零值。完成游戏的总体思路是,两个口袋妖怪将在模拟中与另一个“战斗”,口袋妖怪轮流攻击。 (具有最高速度值的那一个每轮首先进行)攻击口袋妖怪的力量将从“攻击者”身体中减去。
public class Pokemon{
private int health;
private int strength;
private int speed;
/**
* Constructs the pokemon
* @Require:
* health is an integer greater than or equal to 1 but less than or equal to 300
* strength is and integer greater than or equal to 1 but less than or equal to 300
* speed is an integer greater than or equal to 1 but less than or equal to 300
*/
public Pokemon(int health, int strength, int speed){
assert health >= 1;
assert health <= 300;
assert strength >= 1;
assert str