Exemplo n.º 1
0
		internal void Init(PackageCollection packages)
		{
			m_Packages.Clear();

			// Initialize the root package
			m_RootPackage = new Package();
			m_Packages.Add(m_RootPackage);

			// Create a flattened list of packages
			for (int i = 0; i < packages.Count; i++)
			{
				Package package = new Package(packages[i]);
				m_RootPackage.Packages.Add(package);
			}

			// Convert the flattened list of packages into an actual tree
			for (int i = 0; i < m_RootPackage.Packages.Count; i++)
			{
				Package package = m_RootPackage.Packages[i];
				Package parentPackage = FindPackageById(package.ParentId);
				if (parentPackage == null)
					continue;
				parentPackage.Packages.Add(package);
				m_RootPackage.Packages.Remove(package);
				i--;
			}
		}
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            CD cd = new CD("Jón", 5, "engin", false, 50, "Hæ");
            Console.WriteLine(cd.info());

            Console.WriteLine();

            DVD dvd = new DVD("Kalli", "None", true, 120, "Avatart");
            Console.WriteLine(dvd.info());

            Console.WriteLine();

            Package pakki1 = new Package("Palli", "Svoluhofdi 2", "moso", "Katrin", "Leyndo", "Leyndo", 10, 20);
            Console.WriteLine(pakki1.info());

            Console.WriteLine();

            twoDay pakki2 = new twoDay(50,"Palli", "Svoluhofdi 2", "moso", "Katrin", "Leyndo", "Leyndo", 10, 20);
            Console.WriteLine(pakki2.info());

            Console.WriteLine();

            overNight pakki3 = new overNight(50, "Palli", "Svoluhofdi 2", "moso", "Katrin", "Leyndo", "Leyndo", 10, 20);
            Console.WriteLine(pakki3.info());

            Console.ReadLine();
        }
Exemplo n.º 3
0
        int CalculateTotalRibbonRequired(string[] input)
        {
            var total = 0;

            foreach (var line in input)
                total += new Package(line).GetRibbonNeeded();

            return total;
        }
Exemplo n.º 4
0
		internal void Add(Package package)
		{
			if (package == null)
				return;
			Package parentPackage = FindPackageById(package.ParentId);
			if (parentPackage == null)
				parentPackage = m_RootPackage;
			parentPackage.Packages.Add(package);
		}
Exemplo n.º 5
0
		internal void Update(Package packageOld, Package package)
		{
			if (packageOld == null || package == null)
				return;
			Package parentPackageOld = FindPackageById(packageOld.ParentId);
			if (parentPackageOld == null)
				parentPackageOld = m_RootPackage;
			parentPackageOld.Packages.Remove(packageOld);

			Package parentPackage = FindPackageById(package.ParentId);
			if (parentPackage == null)
				parentPackage = m_RootPackage;
			parentPackage.Packages.Add(package);
		}
Exemplo n.º 6
0
		internal void Delete(Package package)
		{
			if (package == null)
				return;
			Package parentPackage = FindPackageById(package.ParentId);
			if (parentPackage == null)
				parentPackage = m_RootPackage;
			parentPackage.Packages.Remove(package);

			foreach (Package childPackage in package.Packages)
			{ // Reparent the children
				parentPackage.Packages.Add(childPackage);
				childPackage.ParentId = parentPackage.Id;
			}

			package.Packages.Clear();
		}