예제 #1
0
        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);
        }
예제 #2
0
 public void PrintShippingReceipt(Customer customer, DeliveryService service)
 {
     Console.WriteLine($@"
         
         {this.Title} was sent to {customer.FullName} by {service.Name}
         
         ");
 }
예제 #3
0
 /*
  * Methods
  */
 public void Ship(Customer customer, DeliveryService service)
 {
     if (!customer.IsLocal)
     {
         //this refers to the referred Product class
         service.Deliver(this, customer);
     }
 }