private static void Main() { var substr = Exceptions.Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Exceptions.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(String.Join(" ", subarr)); var allarr = Exceptions.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(String.Join(" ", allarr)); var emptyarr = Exceptions.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(String.Join(" ", emptyarr)); Console.WriteLine(Exceptions.ExtractEnding("I love C#", 2)); Console.WriteLine(Exceptions.ExtractEnding("Nakov", 4)); Console.WriteLine(Exceptions.ExtractEnding("beer", 4)); //// Console.WriteLine(ExtractEnding("Hi", 100)); Console.WriteLine("23 is {0}.", Exceptions.CheckPrime(23) ? "prime" : "not prime"); Console.WriteLine("33 is {0}.", Exceptions.CheckPrime(23) ? "prime" : "not prime"); List<Exam> peterExams = new List<Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
public static void Main() { try { var substr = StringUtilities.Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = StringUtilities.Subsequence(new[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); ////var allarr = StringUtilities.Subsequence(new[] { -1, 3, 2, 1 }, 0, 4); ////Console.WriteLine(string.Join(" ", allarr)); var emptyarr = StringUtilities.Subsequence(new[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(string.Join(" ", emptyarr)); Console.WriteLine(StringUtilities.ExtractEnding("I love C#", 2)); Console.WriteLine(StringUtilities.ExtractEnding("Nakov", 4)); Console.WriteLine(StringUtilities.ExtractEnding("beer", 4)); ////Console.WriteLine(ExtractEnding("Hi", 100)); int firstNumber = 23; MathUtilities.CheckPrime(firstNumber); int secondNumber = 33; MathUtilities.CheckPrime(secondNumber); Student peter = new Student("Peter", "Petrov"); peter.AddExam(new SimpleMathExam(2)); peter.AddExam(new CSharpExam(55)); peter.AddExam(new CSharpExam(100)); peter.AddExam(new SimpleMathExam(1)); peter.AddExam(new CSharpExam(0)); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); } catch (ArgumentNullException ex) { Console.WriteLine(ex.Message); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (IndexOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main() { var substr = Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(String.Join(" ", subarr)); var allarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(String.Join(" ", allarr)); var emptyarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(String.Join(" ", emptyarr)); Console.WriteLine(ExtractEnding("I love C#", 2)); Console.WriteLine(ExtractEnding("Nakov", 4)); Console.WriteLine(ExtractEnding("beer", 4)); Console.WriteLine(ExtractEnding("Hi", 100)); try { CheckPrime(23); Console.WriteLine("The given number is prime."); } catch (ArgumentException ex) { throw new ArgumentException("The given number must be prime!", ex); } try { CheckPrime(33); Console.WriteLine("The given number is prime."); } catch (ArgumentException ex) { throw new ArgumentException("The given number must be prime!", ex); } List <Exam> peterExams = new List <Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
private static void Main() { var substr = Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Subsequence(new[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); var allarr = Subsequence(new[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(string.Join(" ", allarr)); var emptyarr = Subsequence(new[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(string.Join(" ", emptyarr)); Console.WriteLine(ExtractEnding("I love C#", 2)); Console.WriteLine(ExtractEnding("Nakov", 4)); Console.WriteLine(ExtractEnding("beer", 4)); Console.WriteLine(ExtractEnding("Hi", 100)); try { CheckPrime(23); Console.WriteLine("23 is prime."); } catch (Exception ex) { Console.WriteLine("23 is not prime"); } try { CheckPrime(33); Console.WriteLine("33 is prime."); } catch (Exception ex) { Console.WriteLine("33 is not prime"); } var peterExams = new List <Exam> { new SimpleMathExam(2), new CSharpExam(-55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0) }; var peter = new Student("Peter", "Petrov", peterExams); var peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
public static void Main() { try { var substringOfCharCollection = GenericSubstringSequence<char>.SubstringSequence( "Hello!".ToCharArray(), 2, 3); Console.WriteLine(substringOfCharCollection); var substringOfIntCollection = GenericSubstringSequence<char>.SubstringSequence( new int[] {-1, 3, 2, 1}, 0, 2); Console.WriteLine(String.Join(" ", substringOfIntCollection)); var allCollection = GenericSubstringSequence<char>.SubstringSequence(new int[] {-1, 3, 2, 1}, 0, 4); Console.WriteLine(String.Join(" ", allCollection)); var emptyCollection = GenericSubstringSequence<char>.SubstringSequence(new int[] {-1, 3, 2, 1}, 0, 0); Console.WriteLine(String.Join(" ", emptyCollection)); Console.WriteLine(ExtractorEnds.ExtractEndingOfString("I love C#", 2)); Console.WriteLine(ExtractorEnds.ExtractEndingOfString("Nakov", 4)); Console.WriteLine(ExtractorEnds.ExtractEndingOfString("beer", 4)); //Console.WriteLine(ExtractEnding("Hi", 100)); // Invalid Count! List<int> numbersForCheck = new List<int>() {23, 33}; numbersForCheck.ForEach(PrintIsPrime); List<IExam> peterExams = new List<IExam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; //Student invalidName = new Student("9898Peter", "Petrov", peterExams); //Console.WriteLine(invalidName); Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); } catch (ArgumentNullException ex) { Console.WriteLine(ex.Message); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (FormatException fe) { Console.WriteLine(fe.Message); } }
public static void Main() { try { var substr = Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); var allarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(string.Join(" ", allarr)); var emptyarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(string.Join(" ", emptyarr)); Console.WriteLine(ExtractEnding("I love C#", 2)); Console.WriteLine(ExtractEnding("Nakov", 4)); Console.WriteLine(ExtractEnding("beer", 4)); // Console.WriteLine(ExtractEnding("Hi", 100)); bool is23Prime = CheckPrime(23); Console.WriteLine(is23Prime ? "23 is prime." : "23 is not prime."); bool is33Prime = CheckPrime(33); Console.WriteLine(is33Prime ? "33 is prime." : "33 is not prime."); List <Exam> peterExams = new List <Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); } catch (ArgumentNullException ex) { PrintErrorMessage(ex); } catch (ArgumentOutOfRangeException ex) { PrintErrorMessage(ex); } catch (InvalidOperationException ex) { PrintErrorMessage(ex); } catch (Exception ex) { PrintErrorMessage(ex); } }
public static void Main() { var substr = Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); var allarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(string.Join(" ", allarr)); var emptyarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(string.Join(" ", emptyarr)); Console.WriteLine(ExtractEnding("I love C#", 2)); Console.WriteLine(ExtractEnding("Nakov", 4)); Console.WriteLine(ExtractEnding("beer", 4)); Console.WriteLine(ExtractEnding("Hi", 100)); if (CheckPrime(23)) { Console.WriteLine("23 is prime."); } else { Console.WriteLine("23 is not prime"); } if (CheckPrime(33)) { Console.WriteLine("33 is prime."); } else { Console.WriteLine("33 is not prime"); } List <Exam> peterExams = new List <Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
public static void Main() { var substr = SubArrayMethods.Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = SubArrayMethods.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); var allarr = SubArrayMethods.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(string.Join(" ", allarr)); var emptyarr = SubArrayMethods.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(string.Join(" ", emptyarr)); Console.WriteLine(SubArrayMethods.ExtractEnding("I love C#", 2)); Console.WriteLine(SubArrayMethods.ExtractEnding("Nakov", 4)); Console.WriteLine(SubArrayMethods.ExtractEnding("beer", 4)); try { Console.WriteLine(SubArrayMethods.ExtractEnding("Hi", 100)); } catch (ArgumentNullException ex) { Console.WriteLine(ex.Message); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } Console.WriteLine(string.Format("{0} is prime: {1}", 23, PrimeNumbers.Check(23))); Console.WriteLine(string.Format("{0} is prime: {1}", 33, PrimeNumbers.Check(33))); List <Exam> peterExams = new List <Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
public static void Main() { var substr = Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); var allarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(string.Join(" ", allarr)); var emptyarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(string.Join(" ", emptyarr)); Console.WriteLine(ExtractEnding("I love C#", 2)); Console.WriteLine(ExtractEnding("Nikolay Kostov", 4)); Console.WriteLine(ExtractEnding("beer", 4)); try { Console.WriteLine(ExtractEnding("Hi", 100)); } catch (ArgumentOutOfRangeException exception) { Console.Error.WriteLine(exception.Message); } var primeNumber = 23; Console.WriteLine(primeNumber + " is prime: " + CheckPrime(primeNumber)); var notPrimeNumber = 33; Console.WriteLine(notPrimeNumber + " is prime: " + CheckPrime(notPrimeNumber)); List <Exam> peterExams = new List <Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
static void Main() { var substr = Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Subsequence(new[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(String.Join(" ", subarr)); var allarr = Subsequence(new[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(String.Join(" ", allarr)); var emptyarr = Subsequence(new[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(String.Join(" ", emptyarr)); Console.WriteLine(ExtractEnding("I love C#", 2)); Console.WriteLine(ExtractEnding("Nakov", 4)); Console.WriteLine(ExtractEnding("beer", 4)); //Console.WriteLine(ExtractEnding("Hi", 100)); throws exception : Invalid count int number = 23; Console.WriteLine(IsPrime(number) ? $"{number} is prime" : $"{number} is not prime"); number = 33; Console.WriteLine(IsPrime(number) ? $"{number} is prime" : $"{number} is not prime"); List <IExam> peterExams = new List <IExam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov"); peter.Exams = peterExams; double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine($"{peter.FirstName} {peter.LastName}: Average results = { peterAverageResult:p0}"); }
public static void Main() { var substr = Helpers.Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Helpers.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(String.Join(" ", subarr)); var allarr = Helpers.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(String.Join(" ", allarr)); var emptyarr = Helpers.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(String.Join(" ", emptyarr)); Console.WriteLine(Helpers.ExtractEnding("I love C#", 2)); Console.WriteLine(Helpers.ExtractEnding("Nakov", 4)); Console.WriteLine(Helpers.ExtractEnding("beer", 4)); Console.WriteLine(Helpers.ExtractEnding("Hi", 100)); try { Console.WriteLine(Helpers.ExtractEnding("Hi", 100)); } catch (ArgumentOutOfRangeException exception) { Console.Error.WriteLine(exception.Message); } var primeNumber = 23; Console.WriteLine(primeNumber + " is prime." + Helpers.CheckPrime(primeNumber)); var notPrimeNumber = 23; Console.WriteLine(notPrimeNumber + " is prime." + Helpers.CheckPrime(notPrimeNumber)); List<Exam> peterExams = new List<Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
public static void Main() { var substr = SubArrayMethods.Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = SubArrayMethods.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); var allarr = SubArrayMethods.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(string.Join(" ", allarr)); var emptyarr = SubArrayMethods.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(string.Join(" ", emptyarr)); Console.WriteLine(SubArrayMethods.ExtractEnding("I love C#", 2)); Console.WriteLine(SubArrayMethods.ExtractEnding("Nakov", 4)); Console.WriteLine(SubArrayMethods.ExtractEnding("beer", 4)); try { Console.WriteLine(SubArrayMethods.ExtractEnding("Hi", 100)); } catch (ArgumentNullException ex) { Console.WriteLine(ex.Message); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } Console.WriteLine(string.Format("{0} is prime: {1}", 23, PrimeNumbers.Check(23))); Console.WriteLine(string.Format("{0} is prime: {1}", 33, PrimeNumbers.Check(33))); List<Exam> peterExams = new List<Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
public static void Main() { try { var substr = Utils.Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Utils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); var allarr = Utils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(string.Join(" ", allarr)); var emptyarr = Utils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(string.Join(" ", emptyarr)); Console.WriteLine(Utils.ExtractEnding("I love C#", 2)); Console.WriteLine(Utils.ExtractEnding("Nakov", 4)); Console.WriteLine(Utils.ExtractEnding("beer", 4)); Console.WriteLine(Utils.ExtractEnding("Hi", 100)); } catch (Exception ex) { Console.WriteLine(ex.Message); } var firstNumber = 23; var secondNumber = 33; Console.WriteLine(firstNumber + (Utils.CheckPrime(firstNumber) ? " is prime." : " is not prime")); Console.WriteLine(secondNumber + (Utils.CheckPrime(secondNumber) ? " is prime." : " is not prime")); List <Exam> peterExams = new List <Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
static void Main() { var substr = StringUtils.Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = StringUtils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(String.Join(" ", subarr)); var allarr = StringUtils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(String.Join(" ", allarr)); var emptyarr = StringUtils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(String.Join(" ", emptyarr)); Console.WriteLine(StringUtils.ExtractEnding("I love C#", 2)); Console.WriteLine(StringUtils.ExtractEnding("Nakov", 4)); Console.WriteLine(StringUtils.ExtractEnding("beer", 4)); try { Console.WriteLine(StringUtils.ExtractEnding("Hi", 100)); } catch (ArgumentException ex) { Console.WriteLine("Count is more than the length of the string"); } Console.WriteLine("23 is prime ? -> {0}", MathUtils.IsPrime(23)); Console.WriteLine("33 is prime? -> {0}", MathUtils.IsPrime(33)); List<Exam> peterExams = new List<Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
static void Main() { var substr = MathUtils.Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = MathUtils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(String.Join(" ", subarr)); var allarr = MathUtils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(String.Join(" ", allarr)); var emptyarr = MathUtils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(String.Join(" ", emptyarr)); try { Console.WriteLine(MathUtils.ExtractEnding("I love C#", 2)); Console.WriteLine(MathUtils.ExtractEnding("Nakov", 4)); Console.WriteLine(MathUtils.ExtractEnding("beer", 4)); Console.WriteLine(MathUtils.ExtractEnding("Hi", 100)); } catch (NullReferenceException nre) { Console.WriteLine(nre.Message); } catch (ArgumentOutOfRangeException aore) { Console.WriteLine(aore.Message); } if (MathUtils.CheckPrime(23)) { Console.WriteLine("23 is prime."); } else { Console.WriteLine("23 is not prime"); } if (MathUtils.CheckPrime(33)) { Console.WriteLine("33 is prime."); } else { Console.WriteLine("33 is not prime"); } List<Exam> peterExams = new List<Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
public static void Main() { try { var substringOfCharCollection = GenericSubstringSequence <char> .SubstringSequence( "Hello!".ToCharArray(), 2, 3); Console.WriteLine(substringOfCharCollection); var substringOfIntCollection = GenericSubstringSequence <char> .SubstringSequence( new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(String.Join(" ", substringOfIntCollection)); var allCollection = GenericSubstringSequence <char> .SubstringSequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(String.Join(" ", allCollection)); var emptyCollection = GenericSubstringSequence <char> .SubstringSequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(String.Join(" ", emptyCollection)); Console.WriteLine(ExtractorEnds.ExtractEndingOfString("I love C#", 2)); Console.WriteLine(ExtractorEnds.ExtractEndingOfString("Nakov", 4)); Console.WriteLine(ExtractorEnds.ExtractEndingOfString("beer", 4)); //Console.WriteLine(ExtractEnding("Hi", 100)); // Invalid Count! List <int> numbersForCheck = new List <int>() { 23, 33 }; numbersForCheck.ForEach(PrintIsPrime); List <IExam> peterExams = new List <IExam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; //Student invalidName = new Student("9898Peter", "Petrov", peterExams); //Console.WriteLine(invalidName); Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); } catch (ArgumentNullException ex) { Console.WriteLine(ex.Message); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (FormatException fe) { Console.WriteLine(fe.Message); } }
public static void Main() { try { var substr = Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); var allarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(string.Join(" ", allarr)); var emptyarr = Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(string.Join(" ", emptyarr)); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } // Extracting Substring try { Console.WriteLine(ExtractEnding("I love C#", 2)); Console.WriteLine(ExtractEnding("Nakov", 4)); Console.WriteLine(ExtractEnding("beer", 4)); Console.WriteLine(ExtractEnding("Hi", 100)); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } // Prime Check int numberToCheck = 3; try { CheckPrime(numberToCheck); Console.WriteLine($"{numberToCheck} is prime."); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } // Creating new student and calculating average result try { List <Exam> peterExams = new List <Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peterStudent = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peterStudent.CalcAverageExamResultInPercents(); Console.WriteLine($"Average results = {peterAverageResult:p0}"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (ArgumentNullException ex) { Console.WriteLine(ex.Message); } try { List <Exam> ivanExams = new List <Exam>() { }; Student ivanStudent = new Student("Ivan", "Ivanov", ivanExams); ivanStudent.CheckExams(); double ivanAverageResult = ivanStudent.CalcAverageExamResultInPercents(); Console.WriteLine($"Average results = {ivanAverageResult:p0}"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (ArgumentNullException ex) { Console.WriteLine(ex.Message); } }
public static void Main() { var substr = Utils.Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = Utils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); var allarr = Utils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(string.Join(" ", allarr)); var emptyarr = Utils.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); Console.WriteLine(string.Join(" ", emptyarr)); try { Console.WriteLine(Utils.ExtractEnding("I love C#", 2)); } catch (ArgumentException ex) { Console.WriteLine(ex.ParamName); } try { Console.WriteLine(Utils.ExtractEnding("Nakov", 4)); } catch (ArgumentException ex) { Console.WriteLine(ex.ParamName); } try { Console.WriteLine(Utils.ExtractEnding("beer", 4)); } catch (ArgumentException ex) { Console.WriteLine(ex.ParamName); } try { Console.WriteLine(Utils.ExtractEnding("Hi", 100)); } catch (ArgumentException ex) { Console.WriteLine(ex.ParamName); } Utils.CheckPrime(23); Utils.CheckPrime(33); List<Exam> peterExams = new List<Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }