Example #1
0
        public void Delete(int index)
        {
            if (index < 0 || index > _pencils.Length - 1)
            {
                Console.WriteLine("Index is out of range");
                return;
            }

            for (int i = index; i < _pencils.Length; i++)
            {
                if (index == _pencils.Length - 1)
                {
                    return;
                }

                _pencils[index] = _pencils[index + 1];
            }

            var newArr = new Pencil[_pencils.Length - 1];
        }
Example #2
0
        static void Main(string[] args)
        {
            var pencilsRepository = new PencilsRepository(24);

            var pencil = new Pencil
            {
                Id    = 0,
                Brand = "Marc",
                Price = 25,
                Size  = 25
            };

            pencilsRepository.Add(pencil);
            pencilsRepository.Add(pencil);
            pencilsRepository.Add(pencil);

            pencilsRepository.WriteToFile();

            var pencilNew = pencilsRepository.ReadFromFile();


            Console.ReadKey();
        }
Example #3
0
 public override void Add(Pencil pencil)
 {
     _pencils[_lastIndex++] = pencil;
 }
Example #4
0
 public abstract void Add(Pencil pencil);