2012-03-19 76 views
0

我不知道如何給每個方法運行命名對象逐步

public class Horse extends Animal{ 
int horsenum = 0; 

} 
public void reproduce(Horse h){ 
    horsenum ++; 
    Horse newHorse = new Horse(); //Here is where I would like to name the new horse "newHorse1, newHorse2, etc." 
+0

使'horsenum'靜態,它應該工作.. – 2012-03-19 22:35:44

+0

@MikeChristensen:你確定這將是穩定的?穩定! Geddit? – skaffman 2012-03-19 23:11:08

+0

@skaffman - 除非馬匹在賽道上......那麼你可能會有比賽條件.. – 2012-03-19 23:43:50

回答

0

時間命名的新對象不同的東西添加Horse.Name ofType串的屬性,並將其命名你會...