When creating a new instance (say A) of a class, I want an instance (say B) of another class to be an optional argument of the constructor. If B is given as an argument, then I want the constructor of A to specify that B belongs to A. If not given as an argument, I want my constructor to create a NEW instance (say C) of the same class as where B belong to and specify that this new instance belongs to A.
More specifically, I'm working on an arrival process for a hospital. Arrivals happen according to a stochastic process. I want it to be possible to specify whether an arrival event is regarding an already existing customer (in this case, I should give it as an argument) or that it is going to be a NEW customer, in which case my arrival constructor should create a new instance of customer.
Bcare if the customer is new or existing? if it represents a customer that should be sufficient, andBcan have an attribute indicating whether or not it is a new customerB, doesn't care,Adoes.Bthat indicates if it's new and you can haveAcheck for that with a method, I think you're making this more complicated than it needs to beBa member ofA?