Beispiel #1
0
        public void StartProgram()
        {
            int[] arrFactor;

            ConsoleOutput  consoleOutput  = new ConsoleOutput();
            ConsoleInput   consoleInput   = new ConsoleInput();
            FactorFinder   factorFinder   = new FactorFinder();
            PerfectChecker perfectChecker = new PerfectChecker();
            PrimeChecker   primeChecker   = new PrimeChecker();

            consoleOutput.OutputMessage("Which number Do you want to factor: ");
            consoleInput.UserInput = int.Parse(Console.ReadLine());
            arrFactor = factorFinder.FactorArray(consoleInput.UserInput);
            consoleOutput.OutputMessage("The Factors are: \n");
            consoleOutput.StringJoinArray(arrFactor);
            if (perfectChecker.PerfectNumber(consoleInput.UserInput))
            {
                consoleOutput.OutputMessage($"{consoleInput.UserInput} is a Perfect Number. \n");
            }
            else
            {
                consoleOutput.OutputMessage($"{consoleInput.UserInput} is NOT a Perfect Number. \n");
            }

            if (primeChecker.PrimeNumber(consoleInput.UserInput))
            {
                consoleOutput.OutputMessage($"{consoleInput.UserInput} is a Prime Number. \n");
            }
            else
            {
                consoleOutput.OutputMessage($"{consoleInput.UserInput} is NOT a Prime Number.\n");
            }

            Console.ReadKey();
        }
Beispiel #2
0
        public void FactorFinderTests(int x, int[] expected)
        {
            FactorFinder factors = new FactorFinder();

            int[] result = factors.FactorArray(x);

            Assert.AreEqual(expected, result);
        }
Beispiel #3
0
        public void TestFactorArray(int x, int[] expected)
        {
            FactorFinder findFactor = new FactorFinder();

            int[] result = findFactor.FactorArray(x);

            Assert.AreEqual(expected, result);
        }
Beispiel #4
0
        public void RunFactorFinder()
        {
            ConsoleOutput.DisplayTitle();
            int          input       = ConsoleInput.GetUserInput();
            FactorFinder findFactors = new FactorFinder();

            int[] factors = findFactors.FactorArray(input);

            PrimeChecker   checkPrime   = new PrimeChecker();
            bool           isPrime      = checkPrime.IsPrime(input);
            PerfectChecker checkPerfect = new PerfectChecker();
            bool           isPerfect    = checkPerfect.IsPerfect(input);

            ConsoleOutput.DisplayResults(input, factors, isPrime, isPerfect);
        }