-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPrice.java
More file actions
28 lines (24 loc) · 717 Bytes
/
Price.java
File metadata and controls
28 lines (24 loc) · 717 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
/**Filename: Price
* @author: Kyle Makunga
*@version: 1.0
* Program to: Display the creation of class for inheritance
* To compile: javac Price.java
*To execute: java Price
*/
public class Price {
private double pricePerKg;
public Price(double pricePerKg) {
this.pricePerKg = pricePerKg; //constructor to inilitailize product attribute (price)
}
//getters and setters
public double getPricePerKg() {
return pricePerKg;
}
public void setPricePerKg(double pricePerKg) {
this.pricePerKg = pricePerKg;
}
//method to calculate price
public double calculateTotal(double weight) {
return pricePerKg * weight;
}
}