-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJewellery.java
More file actions
47 lines (33 loc) · 969 Bytes
/
Copy pathJewellery.java
File metadata and controls
47 lines (33 loc) · 969 Bytes
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
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* @author Joel Delgado jode9188
* Prog2 - VT2020
* Assignment 1 - Part 2
* @version: 2.1
*/
import java.text.DecimalFormat;
public class Jewellery extends Valuable {
private static final int PRICEPERJEWEL = 500;
private int jewels;
private final Material material;
public Jewellery(String name, int jewels, String material) {
super(name);
this.jewels = jewels;
this.material = Material.valueOf(material);
}
public int getJewels() {
return jewels;
}
public Material getMaterial() {
return material;
}
@Override
public double getValue() {
return material.getValue() + PRICEPERJEWEL * this.getJewels();
}
@Override
public String toString() {
DecimalFormat df = new DecimalFormat("0.00");
return String.format("%-15s of %s \tgemstones: %10d \tvalue: %11s \t+VAT: %11s",
getName(), getMaterial(), getJewels(), df.format(getValue()), df.format(getValuePlusVAT()));
}
}