-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathDiscountBill.java
More file actions
49 lines (44 loc) · 1.2 KB
/
DiscountBill.java
File metadata and controls
49 lines (44 loc) · 1.2 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
package com.example.task02;
public class DiscountBill extends Bill{
/**
* @discount Скидка в десятичном виде
*/
private final double discount;
DiscountBill(double discount)
{
this.discount=discount;
}
/**
* Выводит скидку в процентах
*
* @return Скидка в процентах
*/
public double getDiscount()
{
return discount*100;
}
/**
* Подсчитывает общую сумму покупки со скидкой!!!
*
* @return общая стоимость покупки со скидкой!!!
*/
@Override
public long getPrice()
{
return Math.round(super.getPrice()*(1-discount));
}
public long calculateAbsoluteDiscount()
{
return super.getPrice()-getPrice();
}
@Override
public String toString()
{
return super.toString()
+ "\nСкидка: "
+ getDiscount() + "%"
+ "%\nАбсолютное значение скидки: "
+ calculateAbsoluteDiscount()
+ "\nИтоговая сумма: " + getPrice();
}
}