static void Main(string[] args) { Product tinkerToys = new Product() { Title = "Tinker Toys", Description = "You can build anything you want", Price = 32.49, Quantity = 25 }; Customer marcus = new Customer() { FirstName = "Marcus", LastName = "Fulbright", IsLocal = false }; DeliveryService UPS = new DeliveryService() { Name = "UPS", TransitType = "train" }; // Ship the tinker toys to Marcus using UPS tinkerToys.Ship(marcus, UPS); tinkerToys.PrintShippingReceipt(marcus, UPS); }
public void PrintShippingReceipt(Customer customer, DeliveryService service) { Console.WriteLine($@" {this.Title} was sent to {customer.FullName} by {service.Name} "); }
/* * Methods */ public void Ship(Customer customer, DeliveryService service) { if (!customer.IsLocal) { //this refers to the referred Product class service.Deliver(this, customer); } }