using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FieldsAndConstructors
{
    class Examples13_16
    {
        //// Kod umieszczony w komentarzach gdyż ilustruje błąd
        //public static void MissingConstructorArgument()
        //{
        //    // Listing 3-13
        //    Uri oops = new Uri();  // Tego wiersza kodu nie uda się skompilować
        //}

        // Listing 3-14
        public class Item
        {
            public Item(decimal price, string name)
            {
                _price = price;
                _name = name;
            }
            private readonly decimal _price;
            private readonly string _name;
        }

        public static void ConstructObject()
        {
            // Listing 3-15
            var item1 = new Item(9.99M, "Syrenka"); 
        }

        // Listing 3-16
        public class ItemWithId
        {
            private static int _lastId;
            private int _id;

            public ItemWithId()
            {
                _id = ++_lastId;
            }
        } 
    }
}
