// ejecting a ball will eject the ball from the machine add it to the rack. public Ball ejectBall() { // we check not to get null reference balls while we are ejecting from machine. if (machine.getNoOfBalls() > 0 && rack.getNoOfBalls() < rack.getSize()) { Ball ejectedBall = machine.ejectBall(); rack.addBall(ejectedBall); return ejectedBall; } // if else return null; } // ejectBall
public int getRackSize() { return rack.getSize(); } // getRackSize