From 505fa48c36b25d0a274cfb06b97fca61e0f77563 Mon Sep 17 00:00:00 2001 From: Jacob Signorovitch Date: Fri, 18 Apr 2025 07:55:33 -0400 Subject: [PATCH] Here. --- streams/src/streams/Main.java | 33 ++++++++++++++++++- .../src/twentyfortyeight/Main.java | 1 - 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/streams/src/streams/Main.java b/streams/src/streams/Main.java index 6ea1657..6560379 100644 --- a/streams/src/streams/Main.java +++ b/streams/src/streams/Main.java @@ -2,6 +2,7 @@ package streams; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Optional; import tester.Tester; @@ -92,4 +93,34 @@ interface PurchaseDB { getPurchasesForSince(List customerIds, int numberOfDaysAgo); } -class Examples {} +class Victims implements CustomerDB { + Map victims; + + Victims() {} + + public Optional getCustomerById(int id) { + return Optional.ofNullable(this.victims.get(id)); + } + + public List 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); + } +} diff --git a/twentyfortyeight/src/twentyfortyeight/Main.java b/twentyfortyeight/src/twentyfortyeight/Main.java index c593db7..314cda3 100644 --- a/twentyfortyeight/src/twentyfortyeight/Main.java +++ b/twentyfortyeight/src/twentyfortyeight/Main.java @@ -183,7 +183,6 @@ class Grid { // Combine numbers that are the same into their sum. Start checking for // combinations from the side the direction is to for each row/column. void combine(int d) { - // Assume left. if (d == 0) { for (int y = 0; y < this.h; y++) { int prv = this.get(0, y);