Advertisement
shady_obeyd

03.Mankind-StartUp.cs

Feb 27th, 2018
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2.  
  3. class StartUp
  4. {
  5.     static void Main()
  6.     {
  7.         string[] studentTokens = ReadInput();
  8.         string[] workerTokens = ReadInput();
  9.  
  10.         string studendFirstName = studentTokens[0];
  11.         string studendSecondName = studentTokens[1];
  12.         string facultyNumber = studentTokens[2];
  13.  
  14.         string workerFirstName = workerTokens[0];
  15.         string workerSecondName = workerTokens[1];
  16.         decimal weekSalary = decimal.Parse(workerTokens[2]);
  17.         decimal hoursPerDay = decimal.Parse(workerTokens[3]);
  18.  
  19.         try
  20.         {
  21.             Student student = new Student(studendFirstName, studendSecondName, facultyNumber);
  22.             Worker worker = new Worker(workerFirstName, workerSecondName, weekSalary, hoursPerDay);
  23.  
  24.             PrintHuman(student);
  25.             Console.WriteLine();
  26.             PrintHuman(worker);
  27.         }
  28.         catch (ArgumentException ex)
  29.         {
  30.             Console.WriteLine(ex.Message);
  31.         }
  32.     }
  33.    
  34.     private static void PrintHuman(Human human)
  35.     {
  36.         Console.WriteLine(human);
  37.     }
  38.  
  39.     private static string[] ReadInput()
  40.     {
  41.         return Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement