I am currently working on an algorithm for comparing two list of objects. Something like this:
I have a lists of sales:
class Sale
{
protected $client;
protected $products (ArrayCollection of Product objects with id and amount);
protected $status;
}
And I am receiving an unordered list of SaleProducts like this:
[
{
'client_id' => 1,
'product_id' => 21,
'amount' => 1
},
]
I parsed this JSON into an array of Product objects like this:
[clientId] => [Products]
But I'm having problems checking this list against the list of Sales previously given. What would it be the right OOP approach for a problem like this?
My first thought was using a Stack of Products and iterating through the Sales and build candidates for each one but I thought that maybe there was a better solution for this
What would it be the right OOP approach for a problem like this?
-- The way that most effectively fulfills your specific requirements. Right now, there's not enough information in your question to make that determination. What does "checking this list against the list of Sales previously given" mean, for example? – Robert Harvey Mar 14 '17 at 17:23