ede3954d86
See notes in "Foreword to the Leanpub Edition"
53 lines
1.7 KiB
Java
53 lines
1.7 KiB
Java
// patterns/recycleb/RecycleB.java
|
|
// (c)2021 MindView LLC: see Copyright.txt
|
|
// We make no guarantees that this code is fit for any purpose.
|
|
// Visit http://OnJava8.com for more book information.
|
|
// {java patterns.recycleb.RecycleB}
|
|
package patterns.recycleb;
|
|
import patterns.trash.*;
|
|
import java.util.*;
|
|
|
|
public class RecycleB {
|
|
public static void main(String[] args) {
|
|
List<Trash> bin = new ArrayList<>();
|
|
ParseTrash.fillBin("trash", bin);
|
|
Bins bins = new Bins(bin);
|
|
bins.show();
|
|
}
|
|
}
|
|
/* Output:
|
|
Loading patterns.trash.Cardboard
|
|
Loading patterns.trash.Paper
|
|
Loading patterns.trash.Aluminum
|
|
Loading patterns.trash.Glass
|
|
Aluminum weight: 1.80 * price: 1.67 = 3.01
|
|
Aluminum weight: 3.40 * price: 1.67 = 5.68
|
|
Aluminum weight: 2.70 * price: 1.67 = 4.51
|
|
Total Aluminum value = 13.19
|
|
Paper weight: 8.00 * price: 0.10 = 0.80
|
|
Paper weight: 6.60 * price: 0.10 = 0.66
|
|
Paper weight: 9.10 * price: 0.10 = 0.91
|
|
Total Paper value = 2.37
|
|
Glass weight: 5.40 * price: 0.23 = 1.24
|
|
Glass weight: 4.30 * price: 0.23 = 0.99
|
|
Glass weight: 3.60 * price: 0.23 = 0.83
|
|
Total Glass value = 3.06
|
|
Cardboard weight: 4.40 * price: 0.11 = 0.48
|
|
Cardboard weight: 2.20 * price: 0.11 = 0.24
|
|
Cardboard weight: 1.20 * price: 0.11 = 0.13
|
|
Total Cardboard value = 0.86
|
|
Cardboard weight: 4.40 * price: 0.11 = 0.48
|
|
Paper weight: 8.00 * price: 0.10 = 0.80
|
|
Aluminum weight: 1.80 * price: 1.67 = 3.01
|
|
Glass weight: 5.40 * price: 0.23 = 1.24
|
|
Aluminum weight: 3.40 * price: 1.67 = 5.68
|
|
Cardboard weight: 2.20 * price: 0.11 = 0.24
|
|
Glass weight: 4.30 * price: 0.23 = 0.99
|
|
Cardboard weight: 1.20 * price: 0.11 = 0.13
|
|
Paper weight: 6.60 * price: 0.10 = 0.66
|
|
Aluminum weight: 2.70 * price: 1.67 = 4.51
|
|
Paper weight: 9.10 * price: 0.10 = 0.91
|
|
Glass weight: 3.60 * price: 0.23 = 0.83
|
|
Total Trash value = 19.48
|
|
*/
|