这就是我想要做的
Making·a·new·object·of·class·Invoice:↵Enter
·the·part·number:32-RJK-45↵Enter
·the·part·description:Phillips-Screw↵Enter
·the·Quantity·of·Items:20↵Enter·
the·Price·Per·Item·with·cents·in·decimals:↵4.50↵↵
Invoice·price·and·amount·together:↵
我尝试以多种方式使用编译器,使用字符串、双精度数和整数作为数量。
这是我的发票页
package week2chapter3;
public class Invoice {
private String partNumber; // instance variable
private String partDescription; // instance variable
private double priceperitem; // double va1rible
private int itemBeingPurchesed;// used to total
private double invoiceAmount;// double that adds invoice amount
// Part Number
public Invoice (String partNumber,String partDescription,double priceperitem,
int itemBeingPurchesed,double invoiceAmount)
{this.partNumber = partNumber;// assign it to instance variable name
// method to get the part number
}
{this.partDescription = partDescription;// assign it to instance variable name
// method to get the part number
}
// Part Price
// validate that the priceperitem is greater than 0.0; if it is not,
// instance variable priceperitem keeps its default initial value of 0.0
public void setpriceperitem(double priceperitem) {
if (priceperitem > 0.0) {// if the balance is valid
this.priceperitem = priceperitem; // assign it to instance variable balance
}
}
我收到几个错误。当我修复一个问题时,我得到未定义的构造函数,当我修复它时,我在我的源页面中得到一个错误,当我修复这些问题时,我得到格式错误。现在 partnumber 在测试页上被读取为错误,而 partDescription 被读取为未定义。
芜湖不芜
相关分类