1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| public class Item
{
private String name, description;
private long barcode;
private double price;
public Item (String name, String description, long barcode, double price)
{
this.name = name;
this.description = description;
this.barcode = barcode;
this.price = price;
}
public Item (String name, long barcode, double price)
{
this (name, "", barcode, price);
}
public double getPrice()
{
return price;
}
public double getPrice (int q)
{
double tot = price * q;
if (q >= 10)
{
tot = tot * 0.95;
}
return tot;
}
} } |
Partager