コード例 #1
0
        static void Main(string[] args)
        {
            // REGISTER
            Register register = new Register("testRegister");

            Job    poulJob = new Job("Programmør", "FiksIT", 12402349, 0.0f);
            Person poul    = new Person(29, "Poul", "Bach", Gender.Male, poulJob);
            int    week    = 2;

            register.AddPerson(poul, week);

            register.printRegister();


            //DICTIONARY
            DictionaryTask dictionaryTask = new DictionaryTask();

            dictionaryTask.superDic.Add(10, "!");
            dictionaryTask.lmaowtfDic.Add(1.0f, true);

            BonusOpgaveClass opgaveClass = new BonusOpgaveClass("Per", 87);

            Dictionary <BonusOpgaveClass, string> bonusOpgaveDictionary = new Dictionary <BonusOpgaveClass, string>();

            bonusOpgaveDictionary.Add(opgaveClass, "Yeet");


            //MATH
            Calculator calc = new Calculator();

            #region
            Console.WriteLine("Add int: " + calc.Add(13, 2));
            Console.WriteLine("Add float: " + calc.Add(2.0f, 1.0f));
            Console.WriteLine("Add string: " + calc.Add("2", "5"));
            Console.WriteLine("Subtract int: " + calc.Subtract(13, 2));
            Console.WriteLine("Subtract float: " + calc.Subtract(2.0f, 1.0f));
            Console.WriteLine("Subtract string: " + calc.Subtract("2", "5"));
            Console.WriteLine("Multiply int: " + calc.Multiply(13, 2));
            Console.WriteLine("Multiply float: " + calc.Multiply(2.0f, 1.0f));
            Console.WriteLine("Multiply string: " + calc.Multiply("2", "5"));
            Console.WriteLine("Divide int: " + calc.Divide(13, 2));
            Console.WriteLine("Divide float: " + calc.Divide(2.0f, 1.0f));
            Console.WriteLine("Divide string: " + calc.Divide("2", "5"));

            Console.WriteLine("Square int: " + calc.Square(13));
            Console.WriteLine("Square float: " + calc.Square(2.0f));
            Console.WriteLine("Square string: " + calc.Square("5"));
            #endregion

            Console.WriteLine(calc.Add("3", 2.1f));
            Console.WriteLine(calc.Add(3, "2.1"));
            Console.WriteLine(calc.Add(3.0f, 2.1f));
            Console.WriteLine(calc.Add(3, 2.1f));
            Console.WriteLine(calc.Add(3.0d, 2.1f));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Register register = new Register();
            var      person1  = new Person("Andreas", "Madsen", 25, new Vehicle[] { new Car("Skoda", "Black"), new Bike("Trek", "Blue") });

            register.AddPerson(person1);
            var person2 = new Person("Bo", "Rasmussen", 34, new Vehicle[] { new Car("Audi", "Grey"), new Bike("Shimano", "Red") });

            register.AddPerson(person2);
            register.RemovePerson(person2);

            List <Person> persons = register.GetPersons();

            foreach (var item in persons)
            {
                Console.WriteLine("Name: {0} Age: {1}", item.GetFullName(), item.age);
                foreach (var vehicle in item.Vehicles)
                {
                    Console.WriteLine(vehicle.GetVehicle());
                }
            }
        }
        static void Main(string[] args)
        {
            Register register = new Register();

            Person person1 = new Person("Jesper Jespersen", 21, "Hans Tausens Vej 22", new Job("Lead Dev", new Salary(55000, "DKK"), new Company("Bricksite ApS", "Normansvej 1", 10)));

            Person person2 = new Person("Rasmus Rasmussen", 10, "Randersvej 1", new Job("CEO", new Salary(120000, "EUR"), new Company("STARtUP", "yeetvej 21", 2)));

            Person person3 = new Person("JONAS Jespersen", 21, "Hans Tausens Vej 22", new Job("Lead Dev", new Salary(55000, "DKK"), new Company("Bricksite ApS", "Normansvej 1", 10)));

            register.AddPerson(person1);
            register.AddPerson(person2);
            register.AddPerson(person3);

            register.GetPeople();
            register.RemovePerson("Jesper Jespersen");
            register.GetPeople();
            register.GetPerson();
            foreach (LogEntry logEntry in register.GetLog())
            {
                Console.WriteLine(logEntry.getAction() + " : " + logEntry.getCreatedAt());
            }
        }