-1
有與所有有關的所有錯誤與價格/Java中的BigDecimal錯誤
import java.math.BigDecimal;
公共類產品{
// Fields
String name;
String description;
BigDecimal price = new BigDecimal(3.0);
int quantity;
String barcode;
String image;
static int count;
// Constructors
public Product()
{
name = "";
description = "";
price = 0;
quantity = 0;
barcode = "";
image = "";
}
public Product(String n, String d, double p, int q, String b, String i)
{
name = n;
description = d;
price = p;
quantity = q;
barcode = b;
image = i;
}
// Get/Set methods
// description getter and setter
public String getDescription()
{
return description;
}
public void setDescription(String d)
{
this.description = d;
}
// name getter and setter
public String getName()
{
return name;
}
public void setName(String d)
{
this.name = d;
}
// price getter and setter
public double getPrice()
{
return price;
}
public void setPrice(double d)
{
this.price = d;
}
// quantity getter and setter
public int getQuantity()
{
return quantity;
}
public void setQuantity(int d)
{
this.quantity = d;
}
// barcode getter and setter
public String getBarcode()
{
return barcode;
}
public void setBarcode(String d)
{
this.barcode = d;
}
// image getter and setter
public String getImage()
{
return image;
}
public void setImage(String d)
{
this.image = d;
}
}
我的問題是,爲什麼是有我所有的價格部分的錯誤。我需要它是一個很大的小數,但如何解決這些錯誤?
感謝您告訴我們錯誤。 –
請正確格式化您的代碼! – isnot2bad
你沒有解釋錯誤在哪裏,你如何得到它們,以及你期望發生什麼。 – tucuxi