我需要制作这个方法,写一个方法reportInStock() 来打印到终端窗口CD 是否有库存或是否被借。如果已借用,还应报告借款人的姓名
我写了这段代码,但无论如何,当我运行打印终端窗口时,它总是显示 cd 可用。
public void borrower(String nameOfBorrower)
/**
*
*/
{
borrower = nameOfBorrower;
borrowed = true;
inStock = false;
}
public void returned()
/**
*
*/
{
borrower = "";
borrowed = false;
inStock = true;
}
public boolean isBorrowed()
/**
*
*/
{
return borrowed;
}
public void reportInStock()
/**
*
*/
{
if(inStock = false)
{
System.out.println("This CD has been borrowed;" + personName);
}
else
{
System.out.println("This CD is available");
}
}