Skip to content

Instantly share code, notes, and snippets.

@arunprabug
Created June 3, 2020 22:56
Show Gist options
  • Save arunprabug/01cb79d4cb55ccb253661652cf4770f5 to your computer and use it in GitHub Desktop.
Save arunprabug/01cb79d4cb55ccb253661652cf4770f5 to your computer and use it in GitHub Desktop.
class Basket
{
private List<Products> products;
public AddProduct(product)
{
if (products.Length > 3) {
throw new Exception("Max 3 products allowed");
}
products.Add(product)
}
}
class Shipment
{
private List<Products> products;
public AddProduct(product)
{
if (products.Length > 3) {
throw new Exception("Max 3 products allowed");
}
products.Add(product)
}
}
abstract class ProductContainer
{
protected List<Products>;
public AddProduct(product)
{
if (products.Length > 3) {
throw new Exception("Max 3 products allowed");
}
products.Add(product)
}
}
class Basket : ProductContainer {}
class Shipment : ProductContainer {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment