Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // C:\Users\kvnna\Source\Repos\Hash-Code-2019\HashCode2019\c_memorable_moments.txt
            string        allFile    = FileReader.ReadFile(@"C:\Users\kvnna\Source\Repos\Hash-Code-2019\HashCode2019\Inputs\d_pet_pictures.txt");
            var           firstLine  = FileReader.GetFirstLine(allFile);
            List <string> otherLines = FileReader.GetOtherLines(allFile);

            curStructure = Parser.ParseAll(firstLine, otherLines);

            ISlideGenerator generator = new ProbabilisticSlideGenerator();

            var slideshow = generator.generateSlide(curStructure.Photos);

            var score = Score.ComputeScore(slideshow);

            PrintOutput(slideshow);
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public static InputReading ParseAll(string firstLine, List <string> otherLines)
        {
            var input          = new InputReading();
            int numberOfPhotos = Int32.Parse(firstLine);

            input.Photos = new List <Photo>();

            input.NumberOfPhotos = numberOfPhotos;

            for (int i = 0; i < otherLines.Count; i++)
            {
                List <string> photoData = otherLines[i].Split(' ').ToList();

                string      orientationString = photoData[0];
                int         numberOfTags      = Int32.Parse(photoData[1]);
                Orientation orientation;

                if (orientationString.Equals("H"))
                {
                    orientation = Orientation.Horizontal;
                }
                else
                {
                    orientation = Orientation.Vertical;
                }

                photoData.RemoveAt(0);
                photoData.RemoveAt(0);

                input.Photos.Add(new Photo()
                {
                    PhotoID     = i,
                    Orientation = orientation,
                    Tags        = photoData
                });
            }

            return(input);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //Collections sample

            CollectionSample cse = new CollectionSample();

            Console.WriteLine(cse.Factorial(5) + "\t" + cse.FactorialRecursion(5));
            Dictionary <int, string> dic = cse.GetNameAndNumbers();

            foreach (int key in dic.Keys)
            {
                Console.WriteLine(dic[key]);
            }
            Console.WriteLine("Please enter the number till which you want prime numbers");

            List <int> pn = cse.GetPrimeNumbers(Convert.ToInt32(Console.ReadLine()));

            foreach (int primeNumber in pn)
            {
                Console.WriteLine(primeNumber);
            }

            //Singleton sample
            SingletonSample sgs  = SingletonSample.CreateSingletonObject();
            SingletonSample sgs1 = SingletonSample.CreateSingletonObject();
            FileSamples     fs1  = new FileSamples();
            FileSamples     fs2  = new FileSamples();

            Console.WriteLine(sgs.GetHashCode() + "\t" + sgs1.GetHashCode());
            Console.WriteLine(fs1.GetHashCode() + "\t" + fs2.GetHashCode());
            //File Samples
            FileSamples fs = new FileSamples();

            fs.WriteTextToFile("C:\\Users\\v-mukri\\Desktop\\SampleFiles\\1.txt", "Hello");
            fs.AppendToFile("C:\\Users\\v-mukri\\Desktop\\SampleFiles\\1.txt", "\nAppending");
            string[] fileLines   = fs.ReadAllLines("C:\\Users\\v-mukri\\Desktop\\SampleFiles\\1.txt");
            string   fileContent = fs.ReadAllText("C:\\Users\\v-mukri\\Desktop\\SampleFiles\\1.txt");

            try
            {
                File.Copy("C:\\Users\\v-mukri\\Desktop\\SampleFiles\\1.txt", "C:\\Users\\v-mukri\\Desktop\\SampleFiles\\2.txt");
            }
            catch (System.IO.IOException e)
            {
                Console.WriteLine(e.GetType());
                if (e.Message.Contains("already exists"))
                {
                    Console.WriteLine("Please choose a different file name");
                }
                try
                {
                    throw new ArithmeticException();
                }
                catch
                {
                    Console.WriteLine("We have never dealt with this kind of exception, we are investigating into it, Arithmetic");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("We have never dealt with this kind of exception, we are investigating into it");
            }
            finally
            {
                Console.WriteLine("Mandatory code to be executed");
            }
            File.Delete("C:\\Users\\v-mukri\\Desktop\\SampleFiles\\1.txt");
            File.Delete("C:\\Users\\v-mukri\\Desktop\\SampleFiles\\1.txt");
            foreach (string samplestring in fileLines)
            {
                Console.WriteLine(samplestring);
            }
            Console.WriteLine(fileContent);

            Program p = new Program();

            p.BaseClassMethod();

            //Classes and Object
            Fruit mango = new Fruit();

            Console.WriteLine("Name:" + mango.name + "\tColor:" + mango.color + "\tTaste:" + mango.taste);
            mango.name  = "Mango";
            mango.color = "Yello";
            mango.taste = "sweet";
            Console.WriteLine("Name:" + mango.name + "\tColor:" + mango.color + "\tTaste:" + mango.taste);
            Fruit orange = new Fruit("Orange", "Soar", "Orange");

            Console.WriteLine("Name:" + orange.name + "\tColor:" + orange.color + "\tTaste:" + orange.taste);

            //Access specifiers
            PPPInheritance      ppp = new PPPInheritance();
            PrivateAndProtected pnp = new PrivateAndProtected();
            int a = pnp.publicVariabel;

            //Method overloading
            MethodOverLoading mol = new MethodOverLoading();

            mol.Add(1, 2);
            mol.Add(1, 2.3);

            //Method overriding
            MORSubClass mor = new MORSubClass();

            mor.SuperClassMethod();

            //Variables sample
            VariableSamples vs = new VariableSamples();

            vs.SampleMethod();

            //Input reading
            InputReading ir = new InputReading();

            ir.ReadInteger();

            //Operators sample
            OperatorsSample os = new OperatorsSample();

            os.Modulus(4, 3);
            a  = 10;
            a %= 5;
            Console.WriteLine(a);
            Console.WriteLine(os.IfAGreaterThanB(1, 6));
            Console.WriteLine(os.IfAEqualsB(1, 1));

            int b = (1 == 2) ? 2 : 1;

            Console.WriteLine(b);
            b = (1 == 1) ? 2 : 1;
            Console.WriteLine(b);

            Console.WriteLine(Math.Floor(12.1));
            Console.WriteLine(Math.Ceiling(12.1));

            //String samples
            StringSamples ss        = new StringSamples();
            string        firstName = "John";
            string        lastName  = "Doe";
            string        name      = $"My full name is: {firstName} {lastName}";

            Console.WriteLine(name);

            //Condition samples
            ConditionSample cs = new ConditionSample();

            cs.Conditions();

            //Loop samples
            LoopSamples ls = new LoopSamples();

            ls.Loop();

            //Statci variable samples
            Console.WriteLine("Static variable value is " + StcObjVariables.a);
            StcObjVariables stcObj = new StcObjVariables(), stcObj1 = new StcObjVariables();

            Console.WriteLine("Object1 variable value is " + stcObj.b);
            Console.WriteLine("Object2 variable value is " + stcObj1.b);
            stcObj.b = 10;
            Console.WriteLine("Object1 variable value is " + stcObj.b);
            Console.WriteLine("Object2 variable value is " + stcObj1.b);
            stcObj.ContinueAndBreak();



            //ArraySamples
            new ArraySamples().ArraySamplesMethod();

            //Method Samples
            MethodSamples ms  = new MethodSamples();
            MethodSamples ms1 = new MethodSamples(2);
            MethodSamples ms2 = new MethodSamples(1, 2);
            int           a1  = ms2.SimpleIntMethod();
            string        b1  = ms2.SimpleStringMethod("a");
            int           v   = MethodSamples.SimpleAdd(1, 3);

            ms2.MyMethod();
            ms2.MyMethod("India");
        }