From ccc62e9f3292edabc74ddbc3eb75ce4086a0a8bd Mon Sep 17 00:00:00 2001 From: FirdavsAX Date: Sun, 24 Sep 2023 19:08:04 +0500 Subject: [PATCH] Firdavs-homework05 --- Lesson05/Lesson05/Candidate.cs | 52 +++++++++++++++++++ Lesson05/Lesson05/CandidateAdult.cs | 12 +++++ Lesson05/Lesson05/CandidateIsNotSuitable.cs | 13 +++++ Lesson05/Lesson05/CandidateShouldMale.cs | 12 +++++ Lesson05/Lesson05/Program.cs | 46 +++++++++++++++- .../Lesson05/ShouldGraduatedUniversity.cs | 13 +++++ 6 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 Lesson05/Lesson05/Candidate.cs create mode 100644 Lesson05/Lesson05/CandidateAdult.cs create mode 100644 Lesson05/Lesson05/CandidateIsNotSuitable.cs create mode 100644 Lesson05/Lesson05/CandidateShouldMale.cs create mode 100644 Lesson05/Lesson05/ShouldGraduatedUniversity.cs diff --git a/Lesson05/Lesson05/Candidate.cs b/Lesson05/Lesson05/Candidate.cs new file mode 100644 index 0000000..d2b0eb0 --- /dev/null +++ b/Lesson05/Lesson05/Candidate.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Lesson05 +{ + internal class Candidate + { + public string FullName { get; set; } + public int Age { get; set; } + public Gender Gender { get; set; } + public Education Education { get; set; } + + public Candidate(string fullName, int age, Gender gender, Education education) + { + FullName = fullName; + Age = age; + Gender = gender; + Education = education; + CheckCandidate(); + } + public void CheckCandidate() + { + if (Age <= 18) + { + throw new CandidateAdult(); + } + if(Gender == Gender.Female) + { + throw new CandidateShouldMale(); + } + if(Education != Education.University && Education != Education.Master) + { + throw new ShouldGraduatedUniversity(); + } + } + } + enum Gender + { + Male = 1, + Female + } + enum Education + { + Master = 1, + University, + College, + School + } +} diff --git a/Lesson05/Lesson05/CandidateAdult.cs b/Lesson05/Lesson05/CandidateAdult.cs new file mode 100644 index 0000000..e5e1120 --- /dev/null +++ b/Lesson05/Lesson05/CandidateAdult.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Lesson05 +{ + internal class CandidateAdult : CandidateIsNotSuitable + { + } +} diff --git a/Lesson05/Lesson05/CandidateIsNotSuitable.cs b/Lesson05/Lesson05/CandidateIsNotSuitable.cs new file mode 100644 index 0000000..27260fc --- /dev/null +++ b/Lesson05/Lesson05/CandidateIsNotSuitable.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Lesson05 +{ + internal class CandidateIsNotSuitable : Exception + { + + } +} diff --git a/Lesson05/Lesson05/CandidateShouldMale.cs b/Lesson05/Lesson05/CandidateShouldMale.cs new file mode 100644 index 0000000..cfda798 --- /dev/null +++ b/Lesson05/Lesson05/CandidateShouldMale.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Lesson05 +{ + internal class CandidateShouldMale : CandidateIsNotSuitable + { + } +} diff --git a/Lesson05/Lesson05/Program.cs b/Lesson05/Lesson05/Program.cs index e8c95d7..5b82471 100644 --- a/Lesson05/Lesson05/Program.cs +++ b/Lesson05/Lesson05/Program.cs @@ -4,7 +4,51 @@ internal class Program { static void Main(string[] args) { - Console.WriteLine("Hello, World!"); + try + { + Console.WriteLine("Ma'lumotaringizni kiriting "); + Console.WriteLine(); + + Console.Write("Ism familiangiz : "); + string name = Console.ReadLine(); + + Console.Write("Yoshingiz : "); + int age = int.Parse(Console.ReadLine()); + + Console.WriteLine("Jinsingiz : 1.Erkak 2.Ayol "); + int gender = int.Parse(Console.ReadLine()); + + Console.WriteLine("Ma'lumotingiz (1.Magistr \t2.Bakalavr \t3.O'rta maxsus \t4.O'rta)"); + int education = int.Parse(Console.ReadLine()); + + Candidate candidate1 = new Candidate(name,age,(Gender)gender, (Education)education); + + } + catch(CandidateAdult) + { + Console.WriteLine("Faqat voyaga yetgan shaxslar qabul qilinadi!"); + } + catch (CandidateShouldMale) + { + Console.WriteLine("Uzr faqat erkak ishchilar qabul qilinadi!"); + } + catch (ShouldGraduatedUniversity) + { + Console.WriteLine("Universitetni tugating!"); + } + catch (Exception) + { + Console.WriteLine("Nimadir xato!"); + } + finally + { + Console.WriteLine("================================================"); + Console.WriteLine("Xizmatlarimizdan foydalanganingiz uchun rahmat!"); + Console.WriteLine(); + } + Main(args); } + + } } \ No newline at end of file diff --git a/Lesson05/Lesson05/ShouldGraduatedUniversity.cs b/Lesson05/Lesson05/ShouldGraduatedUniversity.cs new file mode 100644 index 0000000..973ae6f --- /dev/null +++ b/Lesson05/Lesson05/ShouldGraduatedUniversity.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Lesson05 +{ + internal class ShouldGraduatedUniversity : CandidateIsNotSuitable + { + + } +}