Esempio n. 1
0
        private static void TestBulkInsert()
        {
            var nodelist = new List<StNode>
                           {
                               new StNode("Karnataka"),
                               new StNode("TamilNadu"),
                               new StNode("AndhraPradesh"),
                               new StNode("Orissa"),
                               new StNode("Delhi"),

                           };

            var nodelist2 =
                new List<StNode>
                           {

                               new StNode("District1"),
                               new StNode("District2"),
                               new StNode("District3"),
                               new StNode("District4"),
                               new StNode("District6"),
                               new StNode("District5")
                           };

            StNode stNode = new StNode("India");
            stNode.Insert(nodelist, 1);
            nodelist[1].Add(nodelist2);

            Console.WriteLine(nodelist[1].Children[1].Nodeid == 21? "success TestBulkInsert" : "fail TestBulkInsert") ;
        }
Esempio n. 2
0
        private static void TestNestedObjects()
        {
            var nodelist = new List<StNode>
                           {
                               new StNode("Karnataka"),
                               new StNode("TamilNadu"),
                               new StNode("AndhraPradesh"),
                               new StNode("Orissa"),
                               new StNode("Delhi"),

                           };

            var nodelist2 =
                new List<StNode>
                           {

                               new StNode("District1"),
                               new StNode("District2"),
                               new StNode("District3"),
                               new StNode("District4"),
                               new StNode("District6"),
                               new StNode("District5")
                           };

            nodelist[4].Add(nodelist2);

            StNode District5 = nodelist2[5];
            StNode stNode = new StNode("India");

            stNode.Insert(nodelist, 2);

            Console.WriteLine(District5.Nodeid == 21 ? "success TestNestedObjects" : "fail TestNestedObjects");
        }
Esempio n. 3
0
 public Method2Report(IEnumerable<ICustomer> data, IEnumerable<Carhops> carhopses)
 {
     InitializeComponent();
     _customerData = new List<ICustomer>(data);
     _carhopses = new List<Carhops>(carhopses);
     _customerData.BubbleSort();
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            List<Animal> animals = new List<Animal>()
            {
                new Kitten("Mari",4),
                new Frog("Kyrmit",2,Gender.Female),
                new Dog("Sharo",9,Gender.Male),
                new Dog("Bella",1,Gender.Female),
                new Frog("Jaba kekerica",1,Gender.Female),
                new Frog("Krastava",3,Gender.Male),
                new Dog("Rino",1,Gender.Male),
                new Dog("Keta",13,Gender.Female),
                new Kitten("Maca",9),
                new Kitten("Cyrna maca",10),
                new Tomcat("Bql kotak",2),
                new Tomcat("Tomi",12),
            };

            foreach (var animalType in animals.GroupBy(a => a.GetType()))
            {

                double averageAge = animalType.Select(a => a.Age).Average();
                Console.WriteLine("Average age of {0} is {1:f2}", animalType.Key.Name, averageAge);
            }
        }
Esempio n. 5
0
 public Customer(string firstName, string middleName, string lastName, string ID, string mail,
     string mobilePhone, string permanentAddress, CustomerType customerType,List<IPayment> payments)
 {
     this.FirstName = firstName;
     this.MiddleName = middleName;
     this.LastName = lastName;
     this.ID = ID;
     this.Mail = mail;
     this.MobilePhone = mobilePhone;
     this.PermanentAddress = permanentAddress;
     this.CustomerType = customerType;
     this.payments = new List<IPayment>();
     this.AddPayments(payments);
 }
 static void Main(string[] args)
 {
     IPayment kebab = new Payment("kebabcheta", 6);
     IPayment kufte = new Payment("kifteta", 6);
     List<IPayment> pokupki = new List<IPayment>();
     pokupki.Add(kebab);
     pokupki.Add(kufte);
     Customer a = new Customer("Pepa", "Petrova", "Pitkova", "8101111120",
         "*****@*****.**", "0989888888", "gr.Sofia,kv. Zaharna fabrika", CustomerType.Diamond,pokupki);
     Customer b = a.Clone() as Customer;
     IEnumerable<IPayment> payB = b.Payments;
     IPayment pastyrmichka = new Payment("pastyrma", 15);
     b.AddPayment(pastyrmichka);
     Console.WriteLine(a.Payments.Count());
     Console.WriteLine(b.Payments.Count());
 }
Esempio n. 7
0
        static void input(bool console, string filename = "input.txt")
        {
            string[] line = Console.ReadLine().Split();
            n = Int32.Parse(line[0]); m = Int32.Parse(line[1]);
            roads = new List<Tuple<int, int, short>>();
            int v1, v2;
            short l;
            for (int i = 0; i < m; i++)
            {
                line = Console.ReadLine().Split();
                v1 = Int32.Parse(line[0]) - 1; v2 = Int32.Parse(line[1]) - 1;
                l = Int16.Parse(line[2]);
                roads.Add(Tuple.Create(v1, v2, l));
            }

        }
Esempio n. 8
0
        private static void Main(string[] args)
        {
            int result = 0;
            List<int> fib = new List<int>();
            fib.Add(1);
            fib.Add(2);
            int num = 2;
            while (num < 4e6)
            {
                if (num % 2 == 0)
                    result += num;

                num = fib[fib.Count - 1] + fib[fib.Count - 2];
                fib.Add(num);
            }
            Console.WriteLine(result);
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            List<User> users = new List<User>();

            users.Add(new User("Doug", 2349)); // 28
            users.Add(new User("Jordan", 2102)); // 23
            users.Add(new User("Eric", 2001)); // 25
            users.Add(new User("Johnathan", 1747)); // 22

            int answer = 1;
            foreach (User u in users)
            {
                Console.WriteLine(u.getTasks());
                answer *= u.getTasks();
            }
            Console.WriteLine("Answer = " + answer); // 354200 = 28 * 23 * 25 * 22
            Console.ReadKey();
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("../../../catalog.xml");

            XmlNode rootNode = doc.DocumentElement;

            List<string> albumNames = new List<string>();

            foreach (XmlNode node in rootNode.ChildNodes)
            {
                albumNames.Add(node.ChildNodes[0].InnerText);
            }

            foreach (var albumName in albumNames)
            {
                Console.WriteLine(albumName);
            }
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            int start = 1;
            int end = 100;
            List<int> numbers = new List<int>();

            while(numbers.Count<count)
            {
                try
                {
                    int number = ReadNumber(start, end);
                    numbers.Add(number);
                    start = number;
                }
                catch(FormatException fe)
                {
                    Console.WriteLine("This is not a number!");
                }
                catch(OverflowException oe)
                {
                    Console.WriteLine("This is not an integer!");

                }
                catch(ArgumentOutOfRangeException aore)
                {
                    Console.WriteLine("Number is out of range");

                }
                catch(NotPossibleToCompleteException npe)
                {
                    Console.WriteLine(npe.Message);

                }

            }
            Console.Clear();
            Console.WriteLine("These are input numbers");
            numbers.ForEach(n => Console.WriteLine(n));
        }
Esempio n. 12
0
 private void AddPayments(List<IPayment> payments)
 {
     if (payments.Count() != 0)
     {
         this.payments = payments.ToList();
     }
 }
Esempio n. 13
0
 public object Clone()
 {
     List<IPayment> clonedPayments = new List<IPayment>();
     foreach (var payment in this.Payments)
     {
         var clonedPayment = new Payment(payment.ProductName, payment.Price);
         clonedPayments.Add(clonedPayment);
     }
     Customer cloned = new Customer(this.FirstName, this.MiddleName, this.LastName,
         this.ID, this.Mail, this.MobilePhone, this.PermanentAddress, this.CustomerType, clonedPayments);
     return cloned;
 }
Esempio n. 14
0
 public void Add(List<StNode> nodelist2)
 {
     foreach (var stNode in nodelist2)
     {
         Add(stNode);
     }
 }
Esempio n. 15
0
        static void Main(string[] args)
        {
            double money = (double.Parse(Console.ReadLine()))*1.94;
            string input = Console.ReadLine();
            //string[] inputArray = input.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            int points = 0;
            int currentValue = 0;
            Dictionary<string, int> teams = new Dictionary<string, int>();
            teams.Add("Arsenal", currentValue);
            teams.Add("Chelsea", currentValue);
            teams.Add("Everton", currentValue);
            teams.Add("Liverpool", currentValue);
            teams.Add("Manchester City", currentValue);
            teams.Add("Manchester United", currentValue);
            teams.Add("Southampton", currentValue);
            teams.Add("Tottenham", currentValue);

            List<string> teamWins = new List<string>();

            int matchNumber = 0;

            while (input !="End of the league.")
            {
                string[] inputArray = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                if (inputArray[1].Equals("1"))
                {
                    switch (inputArray[0])
                    {
                        case "Arsenal": teams["Arsenal"] += 3; break;
                        case "Chelsea": teams["Chelsea"] += 3; break;
                        case "Everton": teams["Everton"] += 3; break;
                        case "Liverpool": teams["Liverpool"] += 3; break;
                        case "ManchesterCity": teams["Manchester City"] += 3; break;
                        case "ManchesterUnited": teams["Manchester United"] += 3; break;
                        case "Southampton": teams["Southampton"] += 3; break;
                        case "Tottenham": teams["Tottenham"] += 3; break;

                        default:
                            break;
                    }

                }
                if (inputArray[1].Equals("2"))
                {
                    switch (inputArray[2])
                    {
                        case "Arsenal": teams["Arsenal"] += 3; break;
                        case "Chelsea": teams["Chelsea"] += 3; break;
                        case "Everton": teams["Everton"] += 3; break;
                        case "Liverpool": teams["Liverpool"] += 3; break;
                        case "ManchesterCity": teams["Manchester City"] += 3; break;
                        case "ManchesterUnited": teams["Manchester United"] += 3; break;
                        case "Southampton": teams["Southampton"] += 3; break;
                        case "Tottenham": teams["Tottenham"] += 3; break;

                        default:
                            break;
                    }
                }
                if (inputArray[1].Equals("X"))
                {
                    switch (inputArray[2])
                    {
                        case "Arsenal": teams["Arsenal"] += 1; break;
                        case "Chelsea": teams["Chelsea"] += 1; break;
                        case "Everton": teams["Everton"] += 1; break;
                        case "Liverpool": teams["Liverpool"] += 1; break;
                        case "ManchesterCity": teams["Manchester City"] += 1; break;
                        case "ManchesterUnited": teams["Manchester United"] += 1; break;
                        case "Southampton": teams["Southampton"] += 1; break;
                        case "Tottenham": teams["Tottenham"] += 1; break;

                        default:
                            break;
                    }
                    switch (inputArray[0])
                    {
                        case "Arsenal": teams["Arsenal"] += 1; break;
                        case "Chelsea": teams["Chelsea"] += 1; break;
                        case "Everton": teams["Everton"] += 1; break;
                        case "Liverpool": teams["Liverpool"] += 1; break;
                        case "ManchesterCity": teams["Manchester City"] += 1; break;
                        case "ManchesterUnited": teams["Manchester United"] += 1; break;
                        case "Southampton": teams["Southampton"] += 1; break;
                        case "Tottenham": teams["Tottenham"] += 1; break;

                        default:
                            break;
                    }
                }

                matchNumber++;

                input = Console.ReadLine();
            }

            Console.WriteLine("{0:f2}lv.",(money*matchNumber));
            foreach (var pair in teams)
            {
                Console.WriteLine("{0} - {1} points.",
                pair.Key,
                pair.Value);
            }
        }
        static void Main(string[] args)
        {
            double n = double.Parse(Console.ReadLine());
            string input = "";

            List<string> list = new List<string>();
            int plus1 = 0;
            while (input != "End of the league.")
            {
                plus1++;
                input = Console.ReadLine();
                if (input != "End of the league.")
                {
                     list.Add(input);
                }
            }
            double money = (n * (plus1-1)) * 1.94;
            Console.WriteLine("{0:0.00}lv.",money);

            List<string> winners = new List<string>();
            string myStr = "";
            for (int i = 0; i < list.Count; i++)
            {
                myStr = Regex.Match(list[i], @"\d+").Value;
                if (myStr == "")
                {
                    myStr = "3";
                }

                int myInt = 0;
                myInt = Convert.ToInt32(myStr);

                if (myInt == 1)
                {
                    string firstWord = list[i].Split(' ').FirstOrDefault();
                    winners.Add(firstWord + " - 3 points.");
                    string lastWord = list[i].Split(' ').LastOrDefault();
                    winners.Add(lastWord + " - 0 points.");
                }
                else if (myInt == 2)
                {
                    string lastWord = list[i].Split(' ').LastOrDefault();
                    winners.Add(lastWord + " - 3 points.");
                    string firstWord = list[i].Split(' ').FirstOrDefault();
                    winners.Add(firstWord + " - 0 points.");
                }
                else if (myInt == 3)
                {
                    string firstWord = list[i].Split(' ').FirstOrDefault();
                    winners.Add(firstWord + " - 1 points.");
                    string lastWord = list[i].Split(' ').LastOrDefault();
                    winners.Add(lastWord + " - 1 points.");
                }
            }

            winners.Sort();
            for (int i = 0; i < winners.Count; i++)
            {
                winners[i] = winners[i];

                string newValue = Regex.Replace(winners[i], "([a-z])([A-Z])", "$1 $2");
                Console.WriteLine(newValue);
            }
        }
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] states = new string[n];
            for (int line = 0; line < n; line++)
            {
                states[line] = Console.ReadLine();
            }

            //string[] states = new string[n];
            //states[0] = "1011111";

            List<int> nums = new List<int>();
            nums.Add(GetNum(states[0]));
            int zeroIndex = states[0].IndexOf("0");
            while (zeroIndex != -1)
            {
                states[0] = states[0].Remove(zeroIndex, 1);
                states[0] = states[0].Insert(zeroIndex, "1");
                nums.Add(GetNum(states[0]));
                zeroIndex = states[0].IndexOf("0");
            }
            Console.WriteLine(nums.Count);
            if (n < 2)
            {
                foreach (int ele in nums)
                {
                    Console.WriteLine(ele);
                }
            }
            else
            {
                int k = nums.Count;

                int[] array = new int[k];
                int[] possible = nums.ToArray();
                Combinations(array, 0, possible, 0, k);
            }
        }