Categories
JavaScript Без категория Телерик

Мултиплатформени мобилни приложения с NativeScript

Резултат от курса по Мултиплатформени мобилни приложения с NativeScript:

  • Взет с отличие!
  • Точки: 100
  • Място: 1
  • Февруари – 2016
Categories
JavaScript

Movies Quizz – JS Apps 2015 – Team Rampart

Movies Quizz

Това е игра тип “викторина/тест”, където информацията за филмите се взима от сайт (www.omdbapi.com), предоставящ API за достъп до филмова база данни. Играта предостовя два режима на игра: първияг е “Отговори на въпроса”, а вторият – “История”. Във втория режим играчът се стреми да подреди филмите по правилен хронологичен ред. Играта предоставя уеб система за регистрация и вход, както и статистика, като за целта използва Telerik Backend Services.

Използвани технологии:

  • Telerik Backend Services
  • Bootstrap
  • JQuery, System.js
  • HTML 5
Categories
JavaScript Телерик

Rams and Sheeps – JavaScript Game

Source

Demo

Categories
JavaScript Телерик

JS OOP изпит – сутрешна група

Решение на задачата на сутрешната група на изпита по JavaScript OOP

// item.js
define(function() {
    'use strict';
    var Item;

    Item = (function() {
        var types = ['accessory', 'smart-phone', 'notebook', 'pc', 'tablet'];

        function Item(type, name, price) {
            if (types.indexOf(type) == -1) {
                throw "invalid item type";
            };

            if (name.length < 6 || name.length > 40) {
                throw "invalid item name";
            };

            if (price < 0.0) {
                throw "invalid item price";
            };
            this.type = type;
            this.name = name;
            this.price = price;
        }
        return Item;
    })();
    return Item;
});

// store.js 

define(function() {
    'use strict';
    var Store;
    Store = (function() {
        function Store(storeName) {
            if (storeName.length < 6 || storeName.length > 40) {
                throw "invalid store name";
            }

            this._name = storeName;
            this._items = [];
        };

        Store.prototype.addItem = function(item) {
            if (item.constructor.name !== "Item") {
                throw "invalid item type";
            }

            this._items.push(item);

            return this;
        };

        Store.prototype.getAll = function() {
            var sortedItems = compareBy(this._items, "name");

            return sortedItems;
        };

        Store.prototype.getSmartPhones = function() {
            var items = [];

            this._items.forEach(function(item) {
                if (item.type === 'smart-phone') {
                    items.push(item);
                }
            });

            var sortedItems = compareBy(items, "name");

            return sortedItems;
        };

        Store.prototype.getMobiles = function() {
            var items = [];

            this._items.forEach(function(item) {
                if (item.type === 'smart-phone' || item.type === 'tablet') {
                    items.push(item);
                }
            });

            var sortedItems = compareBy(items, "name");

            return sortedItems;
        };

        Store.prototype.getComputers = function() {
            var items = [];

            this._items.forEach(function(item) {
                if (item.type === 'pc' || item.type === 'notebook') {
                    items.push(item);
                }
            });

            var sortedItems = compareBy(items, "name");

            return sortedItems;
        };

        Store.prototype.filterItemsByType = function(type) {
            var items = [];

            this._items.forEach(function(item) {
                if (item.type === type) {
                    items.push(item);
                }
            });

            var sortedItems = compareBy(items, "name");

            return sortedItems;
        };

        Store.prototype.filterItemsByPrice = function(options) {
            var minPrice = 0;
            var maxPrice = 999999999.99;
            var items = [];

            if (options) {
                minPrice = options.min || minPrice;
                maxPrice = options.max || maxPrice;
            }

            this._items.forEach(function(item) {
                if (item.price >= minPrice && item.price <= maxPrice) {
                    items.push(item);
                }
            });
            var sortedItems = compareBy(items, "price");
            return sortedItems;
        };
        Store.prototype.countItemsByType = function() {
            var itemTypes = [];
            for (var i = 0; i < this._items.length; i++) {
                if (itemTypes[this._items[i].type]) {
                    itemTypes[this._items[i].type]++;
                } else {
                    itemTypes[this._items[i].type] = 1;
                }
            }
            return itemTypes;
        };
        Store.prototype.filterItemsByName = function(part) {
            var items = [];
            this._items.forEach(function(item) {
                if (item.name.toLowerCase().indexOf(part.toLowerCase()) >= 0) {
                    items.push(item);
                }
            });

            var sortedItems = compareBy(items, "name");

            return sortedItems;
        };

        function compareBy(data, field) {
            data.sort(function(a, b) {
                if (a[field] < b[field]) return -1;
                if (a[field] > b[field])
                    return 1;
                return 0;
            });

            return data;
        };

        return Store;
    })();

    return Store;
});
Categories
JavaScript Телерик

Комбинации на числа по търсена сума

Това е решението на първата задача от изпита по JavaScript основи, проведен на 19 май 2014 година в Телерик Академия.

В задачата се иска да се намерят всички възможни варианти на автомобили, камиони и триколки, на които сумата на гумите да е равен на определено число.

Решението на задачата е само с цикли, без рекурсия. Използват се комбинации.

function findPermutations(n) {
    var tires = [3, 4, 10];
    var buffer = new Array(n + 1);
    for (var i = 0; i <= n; ++i)
        buffer[i] = new Array(tires.length + 1);
    for (var j = 1; j <= tires.length; ++j)
        buffer[0][j] = 1;
    for (i = 1; i <= n; ++i) {
        buffer[i][0] = 0;
        for (j = 1; j <= tires.length; ++j) {
            var value = buffer[i][j − 1];
            if (tires[j − 1] <= i)
                value += buffer[i − tires[j − 1]][j];
            buffer[i][j] = value;
        }
    }
    return buffer[n][tires.length];
}
Categories
HTML / CSS

Резултат от изпита по CSS

Точки: 259 от 300

Точки по задачи

  1. 64 от 100 точки
  2. 95 от 100 точки
  3. 100 от 100 точки

Общ брой участници: 698

Класиране: 163 място

Categories
Телерик

Резултат от изпита по ООП в BGCoder

Изпита по Обектно-ориентирано програмиране на C# приключи!

Резултът в BGCoder е място 22 от 258 в сутрешната група и точки 162 от 200!

Точките по задачи са:

– 100 / 100 на първа задача;

– 62 / 100 на втора задача.

В очакване на оценката от трейнърите в Академията 🙂

Categories
Visual C# Телерик

Задача: Nightmare On Code Street

Решение

using System;

namespace NightmareOnCodeStreet {
  class Program {
    static void Main() {
      string number = Console.ReadLine();
      char[] numbersList = number.ToCharArray();
      int size = numbersList.Length;
      if (numbersList[0] - '0' < 0) {
        for (int i = 0; i < numbersList.Length - 1; i++) {
          numbersList[i] = numbersList[i + 1];
        }
        size--;
      }
      int counter = 0;
      int sum = 0;
      for (int i = 0; i < size; i++) {
        if (i % 2 != 0) {
          if (Char.IsDigit(numbersList[i])) {
            counter++;
            sum += (int)(numbersList[i] - '0');
          }
        }
      }
      Console.WriteLine("{0} {1}", counter, sum);
    }
  }
}

Categories
Visual C# Телерик

Задача: Kaspichania Boats

Решение

using System;

namespace KaspichaniaBoats {
  class Program {
    static void Main() {
      int n = int.Parse(Console.ReadLine());
      int boatWidth = 2 * n + 1;

      int dots = 1;
      for (int i = 0; i < n; i++) {
        Console.Write(new string('.', n - i));
        if (i == 0) {
          Console.Write(new string('*', 1));
        } else if (i == 1) {
          Console.Write(new string('*', 3));
        } else {
          Console.Write("*");
          Console.Write(new string('.', dots));
          Console.Write("*");
          Console.Write(new string('.', dots));
          Console.Write("*");
          dots++;
        }
        Console.Write(new string('.', n - i));
        Console.WriteLine();
      }
      Console.WriteLine(new string('*', boatWidth));
      int counter = 1;
      dots = n - 2;
      for (int i = 1; i <= n / 2; i++) {
        Console.Write(new string('.', i));
        Console.Write(new string('*', 1));
        Console.Write(new string('.', dots));
        Console.Write(new string('*', 1));
        Console.Write(new string('.', dots));
        Console.Write(new string('*', 1));
        Console.Write(new string('.', i));
        dots--;
        counter++;
        Console.WriteLine();
      }
      Console.Write(new string('.', counter));
      Console.Write(new string('*', boatWidth - 2 * counter));
      Console.Write(new string('.', counter));
    }
  }
}
Categories
Visual C# Телерик

Задача: 2-4-8

Решение

using System;

namespace _2_4_8 {
  class Program {
    static void Main() {
      decimal a = decimal.Parse(Console.ReadLine());
      decimal b = decimal.Parse(Console.ReadLine());
      decimal c = decimal.Parse(Console.ReadLine());

      decimal r = 0;
      switch ((int) b) {
      case 2:
        r = a % c;
        break;
      case 4:
        r = a + c;
        break;
      case 8:
        r = a * c;
        break;
      }

      int remainder = r % 4;
      if (remainder == 0) {
        Console.WriteLine(r / 4);
      } else {
        Console.WriteLine(remainder);
      }
      Console.WriteLine(r);
    }
  }
}