-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiscountItem.java
More file actions
44 lines (35 loc) · 863 Bytes
/
DiscountItem.java
File metadata and controls
44 lines (35 loc) · 863 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
package assignment6;
/**
* An item of the day object. It has a class variable discount used to calculate its discounted price.
*
* @author Rían Adamian
* @since 13/11/2018
*/
public class DiscountItem extends Item{
private String name;
private double price;
private String type;
private double discount;
public DiscountItem(Item item, double discount) {
this.name = item.getName();
this.price = item.getPrice();
this.type = item.getType();
this.discount = discount;
}
@Override
public String getName() {
return this.name;
}
@Override
public double getPrice() {
return (this.price * this.discount);
}
@Override
public String getType() {
return this.type;
}
@Override
public String toString() {
return (this.type + ": " + this.name + ", Price: " + this.price + ", Discounted Price: " + this.getPrice());
}
}