Created
June 3, 2020 22:56
-
-
Save arunprabug/01cb79d4cb55ccb253661652cf4770f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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