-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegular.java
More file actions
51 lines (42 loc) · 1.15 KB
/
Copy pathRegular.java
File metadata and controls
51 lines (42 loc) · 1.15 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
/*
* Created by Jasque Saydyk and Kaitlyn Grubb
* In-Class Assignment 3
* CS 386
* 14 March 2018
* Description - This class represents any regular product
*/
import java.text.DecimalFormat;
public class Regular implements Product{
private String name;
private double price;
private Placement place;
/**
* Initializes a regular product
* @param name - Of the product
* @param price - Of the product
* @param place - Location of the product
*/
public Regular(String name, double price, Placement place){
this.name = name;
this.price = price;
this.place = place;
}
/**
* Returns the name of the product
* @return name of the product
*/
public String getName() {
return this.name;
}
/**
* Calculates the price of the product based on several factors
* Requirement: The price is calculated by multiplying the unit price to the discount
* @return The price of the product, formated to a standard price form of #.##
*/
public double calcPrice() {
double result = price * place.getDiscount();
DecimalFormat df = new DecimalFormat("#.##");
result = Double.parseDouble(df.format(result));
return result;
}
}