Here.
This commit is contained in:
@@ -2,6 +2,7 @@ package streams;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import tester.Tester;
|
import tester.Tester;
|
||||||
|
|
||||||
@@ -92,4 +93,34 @@ interface PurchaseDB {
|
|||||||
getPurchasesForSince(List<Integer> customerIds, int numberOfDaysAgo);
|
getPurchasesForSince(List<Integer> customerIds, int numberOfDaysAgo);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Examples {}
|
class Victims implements CustomerDB {
|
||||||
|
Map<Integer, Customer> victims;
|
||||||
|
|
||||||
|
Victims() {}
|
||||||
|
|
||||||
|
public Optional<Customer> getCustomerById(int id) {
|
||||||
|
return Optional.ofNullable(this.victims.get(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Customer> getAllCustomers() {
|
||||||
|
return this.victims.values().stream().toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Examples {
|
||||||
|
Customer borace, germany, vietnam;
|
||||||
|
Inventory cabbages, cinderBlocks;
|
||||||
|
LineItem lottaCabbages, oneCinderBlock;
|
||||||
|
Purchase profit;
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
borace = new Customer(0, "Borace");
|
||||||
|
borace = new Customer(0, "Germany");
|
||||||
|
borace = new Customer(0, "Vietnam");
|
||||||
|
cabbages = new Inventory(0, "Expensive cabbages.", 28);
|
||||||
|
cinderBlocks = new Inventory(1, "Cinder blocks.", 1);
|
||||||
|
lottaCabbages = new LineItem(0, 54);
|
||||||
|
oneCinderBlock = new LineItem(1, 1);
|
||||||
|
profit = new Purchase(0, List.of(lottaCabbages, oneCinderBlock), 0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -183,7 +183,6 @@ class Grid {
|
|||||||
// Combine numbers that are the same into their sum. Start checking for
|
// Combine numbers that are the same into their sum. Start checking for
|
||||||
// combinations from the side the direction is to for each row/column.
|
// combinations from the side the direction is to for each row/column.
|
||||||
void combine(int d) {
|
void combine(int d) {
|
||||||
// Assume left.
|
|
||||||
if (d == 0) {
|
if (d == 0) {
|
||||||
for (int y = 0; y < this.h; y++) {
|
for (int y = 0; y < this.h; y++) {
|
||||||
int prv = this.get(0, y);
|
int prv = this.get(0, y);
|
||||||
|
Reference in New Issue
Block a user