好的,所以我已经发布了第一部分(我没有获得热狗机销售的正确输出)并获得了大量的帮助,但现在我无法想出从所有不同的展台返回正确的总数.我通过使用'this'关键字让支架增加,但我无法弄清楚如何让静态getTotal正确地增加所有支架.
public class HotDogStand {
//instance variable declaration
private int IDNumber;
private int hotDogsSold=0;
private static int totalSold=0;
//constructor
public HotDogStand(int ID, int sold)
{
this.IDNumber=ID;
this.hotDogsSold=sold;
}
//sets ID for all the stands
public void setID(int ID)
{
this.IDNumber=ID;
}
public int getID()
{
return IDNumber;
}
//invoked each time a stand makes a sale
public void justSold()
{
this.hotDogsSold++;
totalSold=hotDogsSold;
}
//gets the totals for the different stands
public int getSold()
{
return this.hotDogsSold;
}
// returns total …Run Code Online (Sandbox Code Playgroud)