-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaterial.java
More file actions
63 lines (52 loc) · 1.41 KB
/
Copy pathMaterial.java
File metadata and controls
63 lines (52 loc) · 1.41 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.text.DecimalFormat;
public class Material{
/**
* The new line separator
*/
private final String NL = System.getProperty("line.separator");
/**
* This atribute stores the material name
*/
private String name;
/**
* This atribute stores the price per m2 of this material
*/
private Double pricePerm2;
/**
* Constructor method
*
* @param name
* the Material's name
* @param material
* the Material's price per m2
*/
public Material(String name, Double pricePerm2) {
this.name = name;
this.pricePerm2 = pricePerm2;
}
/**
* Getter method of atribute name
* @return atribute name
*/
public String getName() {
return this.name;
}
/**
* Getter method of atribute pricePerm2
* @return atribute pricePerm2
*/
public double getPricePerm2() {
return this.pricePerm2;
}
/**
* This method generates and returns an String with
* the information of the Material object.
*/
public String toString() {
DecimalFormat myFormat = new DecimalFormat("#0.00");
StringBuilder sb = new StringBuilder();
sb.append("Name: " + this.name + "\t");
sb.append("Price per m2: " + myFormat.format(this.pricePerm2) + " euros" + NL);
return sb.toString();
}
}