forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.java
More file actions
26 lines (20 loc) · 892 Bytes
/
Calculator.java
File metadata and controls
26 lines (20 loc) · 892 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
import java.lang.reflect.Array;
import java.util.ArrayList;
public class Calculator {
ArrayList<Product> products = new ArrayList<>();
public void addProduct(Product product){ //method for add new product in array
this.products.add(product);
}
public float getFinalPrice(){ //method using for get final price
float sum = 0;
for(int i = 0; i <= products.size() - 1; i++){
sum = sum + products.get(i).price;
}
return sum;
}
public void printAllProducts(){ //method using for get all list of products
for(int i = 0; i <= products.size() - 1; i++){
System.out.println(products.get(i).name);
}
}
}