我有以下代码:
public class InventoryItem {
//fields
private Product productObject;
private int quantity;
/**
* Constructor
*
* @param quantity
*/
public InventoryItem(new Product, int quantity) {
this.quantity = quantity;
}
public InventoryItem(String productName, double cost, int quantity) {
this.productObject = new Product(productName,cost);
this.quantity = quantity;
}
/**
* Method to set new name for product in inventory
*
* @param newProductName
*/
public void setProductName(String newProductName) {
productObject.setProductName(newProductName);
}
我只是从main调用它,但是我希望能够在编写时来回移动。例如,假设我运行程序并键入 cd my_fike ,所以我错过了'l',而没有写 my_file ,而是写了my_fike。当我按<-返回并删除错误时,它显示“ cd my_fike ^ [[D ]”。有帮助吗?